Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

refactor(ui): unify empty states

Predidit7df77b66313c
diff --git a/lib/bean/widget/empty_state_widget.dart b/lib/bean/widget/empty_state_widget.dart
new file mode 100644
index 00000000..ea5c444b
--- /dev/null
+++ b/lib/bean/widget/empty_state_widget.dart
@@ -0,0 +1,45 @@
+import 'package:flutter/material.dart';
+
+/// Shared empty state following the onboarding badge idiom:
+/// a tonal circular badge with an icon above a bold title.
+class GeneralEmptyState extends StatelessWidget {
+ const GeneralEmptyState({
+ super.key,
+ required this.icon,
+ required this.title,
+ });
+
+ final IconData icon;
+ final String title;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = Theme.of(context).colorScheme;
+ final textTheme = Theme.of(context).textTheme;
+
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Container(
+ width: 64,
+ height: 64,
+ decoration: BoxDecoration(
+ color: colorScheme.secondaryContainer,
+ shape: BoxShape.circle,
+ ),
+ child: Icon(
+ icon,
+ size: 32,
+ color: colorScheme.onSecondaryContainer,
+ ),
+ ),
+ const SizedBox(height: 20),
+ Text(
+ title,
+ textAlign: TextAlign.center,
+ style: textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),
+ ),
+ ],
+ );
+ }
+}
diff --git a/lib/pages/collect/collect_page.dart b/lib/pages/collect/collect_page.dart
index c054d76b..e29333fc 100644
--- a/lib/pages/collect/collect_page.dart
+++ b/lib/pages/collect/collect_page.dart
@@ -9,6 +9,7 @@ import 'package:kazumi/bean/card/bangumi_card.dart';
import 'package:kazumi/pages/collect/collect_controller.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
import 'package:kazumi/bean/widget/collect_button.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/modules/collect/collect_sync_plan.dart';
import 'package:kazumi/services/storage/storage.dart';
@@ -236,7 +237,10 @@ class _CollectPageState extends State<CollectPage>
);
} else {
return const Center(
- child: Text('啊嘞, 没有追番的说 (´;ω;`)'),
+ child: GeneralEmptyState(
+ icon: Icons.favorite_border_rounded,
+ title: '暂无追番内容',
+ ),
);
}
}
diff --git a/lib/pages/download/download_page.dart b/lib/pages/download/download_page.dart
index e8ad4633..52ba69c7 100644
--- a/lib/pages/download/download_page.dart
+++ b/lib/pages/download/download_page.dart
@@ -3,6 +3,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/modules/download/download_module.dart';
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/pages/download/download_controller.dart';
@@ -53,7 +54,12 @@ class _DownloadPageState extends State<DownloadPage> {
// bangumi gets a fresh default instead of a stale cached one.
_expanded.removeWhere((key, _) => !recordKeys.contains(key));
if (recordKeys.isEmpty) {
- return const Center(child: DownloadEmptyState());
+ return const Center(
+ child: GeneralEmptyState(
+ icon: Icons.download_rounded,
+ title: '暂无下载内容',
+ ),
+ );
}
return ListView.builder(
padding: const EdgeInsets.all(16),
diff --git a/lib/pages/download/download_widgets.dart b/lib/pages/download/download_widgets.dart
index ec4d866d..e7b09136 100644
--- a/lib/pages/download/download_widgets.dart
+++ b/lib/pages/download/download_widgets.dart
@@ -337,38 +337,3 @@ class _EpisodeStatusBadge extends StatelessWidget {
);
}
}
-
-/// Empty state for the download page, following the onboarding badge idiom.
-class DownloadEmptyState extends StatelessWidget {
- const DownloadEmptyState({super.key});
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = Theme.of(context).colorScheme;
- final textTheme = Theme.of(context).textTheme;
-
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: 64,
- height: 64,
- decoration: BoxDecoration(
- color: colorScheme.secondaryContainer,
- shape: BoxShape.circle,
- ),
- child: Icon(
- Icons.download_rounded,
- size: 32,
- color: colorScheme.onSecondaryContainer,
- ),
- ),
- const SizedBox(height: 20),
- Text(
- '暂无下载内容',
- style: textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),
- ),
- ],
- );
- }
-}
diff --git a/lib/pages/history/history_page.dart b/lib/pages/history/history_page.dart
index d9200639..34f44337 100644
--- a/lib/pages/history/history_page.dart
+++ b/lib/pages/history/history_page.dart
@@ -3,6 +3,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
import 'package:kazumi/bean/card/bangumi_history_card.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/pages/history/history_controller.dart';
import 'package:kazumi/utils/constants.dart';
@@ -111,24 +112,10 @@ class _HistoryPageState extends State<HistoryPage> {
if (historyController.histories.isNotEmpty) {
return contentGrid;
} else {
- return Center(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(
- Icons.history_rounded,
- size: 72,
- color:
- Theme.of(context).colorScheme.outline.withValues(alpha: 0.5),
- ),
- const SizedBox(height: 16),
- Text(
- '没有找到历史记录',
- style: Theme.of(context).textTheme.titleMedium?.copyWith(
- color: Theme.of(context).colorScheme.outline,
- ),
- ),
- ],
+ return const Center(
+ child: GeneralEmptyState(
+ icon: Icons.history_rounded,
+ title: '暂无历史记录',
),
);
}
diff --git a/lib/pages/logs/logs_page.dart b/lib/pages/logs/logs_page.dart
index a3681c18..bdf46bb0 100644
--- a/lib/pages/logs/logs_page.dart
+++ b/lib/pages/logs/logs_page.dart
@@ -5,6 +5,7 @@ import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/services.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
class LogsPage extends StatefulWidget {
const LogsPage({super.key});
@@ -178,7 +179,10 @@ class _LogsPageState extends State<LogsPage> {
if (_logLines.isEmpty) {
return const Center(
- child: Text('没有数据'),
+ child: GeneralEmptyState(
+ icon: Icons.receipt_long_rounded,
+ title: '暂无日志',
+ ),
);
}