Improve UI of empty Explore and Category pages.

This commit is contained in:
2025-01-26 12:35:49 +08:00
parent ba4eff66db
commit 2534c55ffb
4 changed files with 42 additions and 21 deletions

View File

@@ -229,7 +229,7 @@
"Clear History": "清除历史",
"Are you sure you want to clear your history?": "确定要清除您的历史记录吗?",
"No Explore Pages": "没有探索页面",
"Add a comic source in home page": "在主页添加一个漫画源",
"Please add some sources": "请添加一些源",
"Please check your settings": "请检查您的设置",
"No Category Pages": "没有分类页面",
"Chapter @ep": "第 @ep 章",
@@ -317,7 +317,8 @@
"Set comic source list url": "设置漫画源列表URL",
"Deselect All": "取消全选",
"Add keyword": "添加关键词",
"Keyword": "关键词"
"Keyword": "关键词",
"Manage": "管理"
},
"zh_TW": {
"Home": "首頁",
@@ -549,7 +550,7 @@
"Clear History": "清除歷史",
"Are you sure you want to clear your history?": "確定要清除您的歷史記錄嗎?",
"No Explore Pages": "沒有探索頁面",
"Add a comic source in home page": "在主頁添加一個漫畫源",
"Please add some sources": "請添加一些源",
"Please check your settings": "請檢查您的設定",
"No Category Pages": "沒有分類頁面",
"Chapter @ep": "第 @ep 章",
@@ -637,6 +638,7 @@
"Set comic source list url": "設置漫畫源列表URL",
"Deselect All": "取消全選",
"Add keyword": "添加關鍵詞",
"Keyword": "關鍵詞"
"Keyword": "關鍵詞",
"Manage": "管理"
}
}

View File

@@ -6,6 +6,7 @@ class NetworkError extends StatelessWidget {
required this.message,
this.retry,
this.withAppbar = true,
this.buttonText,
});
final String message;
@@ -14,6 +15,8 @@ class NetworkError extends StatelessWidget {
final bool withAppbar;
final String? buttonText;
@override
Widget build(BuildContext context) {
var cfe = CloudflareException.fromString(message);
@@ -60,7 +63,7 @@ class NetworkError extends StatelessWidget {
else
FilledButton(
onPressed: retry,
child: Text('Retry'.tl),
child: Text(buttonText ?? 'Retry'.tl),
),
],
),

View File

@@ -10,6 +10,7 @@ import 'package:venera/utils/ext.dart';
import 'package:venera/utils/translations.dart';
import 'category_comics_page.dart';
import 'comic_source_page.dart';
class CategoriesPage extends StatefulWidget {
const CategoriesPage({super.key});
@@ -63,23 +64,31 @@ class _CategoriesPageState extends State<CategoriesPage> {
appdata.settings.removeListener(onSettingsChanged);
}
Widget buildEmpty() {
var msg = "No Category Pages".tl;
msg += '\n';
VoidCallback onTap;
if (ComicSource.isEmpty) {
msg += "Please add some sources".tl;
onTap = () {
context.to(() => ComicSourcePage());
};
} else {
msg += "Please check your settings".tl;
onTap = addPage;
}
return NetworkError(
message: msg,
retry: onTap,
withAppbar: false,
buttonText: "Manage".tl,
);
}
@override
Widget build(BuildContext context) {
if (categories.isEmpty) {
var msg = "No Category Pages".tl;
msg += '\n';
if (ComicSource.isEmpty) {
msg += "Add a comic source in home page".tl;
} else {
msg += "Please check your settings".tl;
}
return NetworkError(
message: msg,
retry: () {
setState(() {});
},
withAppbar: false,
);
return buildEmpty();
}
return Material(

View File

@@ -5,6 +5,7 @@ import 'package:venera/foundation/appdata.dart';
import 'package:venera/foundation/comic_source/comic_source.dart';
import 'package:venera/foundation/res.dart';
import 'package:venera/foundation/state_controller.dart';
import 'package:venera/pages/comic_source_page.dart';
import 'package:venera/pages/search_result_page.dart';
import 'package:venera/pages/settings/settings_page.dart';
import 'package:venera/utils/ext.dart';
@@ -122,15 +123,21 @@ class _ExplorePageState extends State<ExplorePage>
Widget buildEmpty() {
var msg = "No Explore Pages".tl;
msg += '\n';
VoidCallback onTap;
if (ComicSource.isEmpty) {
msg += "Add a comic source in home page".tl;
msg += "Please add some sources".tl;
onTap = () {
context.to(() => ComicSourcePage());
};
} else {
msg += "Please check your settings".tl;
onTap = addPage;
}
return NetworkError(
message: msg,
retry: onSettingsChanged,
retry: onTap,
withAppbar: false,
buttonText: "Manage".tl,
);
}