Skip to content

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

refactor(ui): unify M3E empty states and simplify state rendering

Predidit4b05b11f8ac7
diff --git a/lib/bean/widget/bangumi_mirror_error_widget.dart b/lib/bean/widget/bangumi_mirror_error_widget.dart
index e0d9b4ff..91843bd5 100644
--- a/lib/bean/widget/bangumi_mirror_error_widget.dart
+++ b/lib/bean/widget/bangumi_mirror_error_widget.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/services/storage/storage.dart';
class BangumiMirrorErrorWidget extends StatelessWidget {
@@ -23,7 +24,7 @@ class BangumiMirrorErrorWidget extends StatelessWidget {
icon: Icons.cloud_off_rounded,
onRetry: onRetry,
actions: [
- GeneralErrorButton.tonal(
+ StateActionButton.tonal(
onPressed: () async {
await context.pushNamed('/settings/webdav/');
onSettingsReturned?.call();
diff --git a/lib/bean/widget/empty_state_widget.dart b/lib/bean/widget/empty_state_widget.dart
index ea5c444b..e6eaf162 100644
--- a/lib/bean/widget/empty_state_widget.dart
+++ b/lib/bean/widget/empty_state_widget.dart
@@ -1,45 +1,74 @@
import 'package:flutter/material.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
-/// Shared empty state following the onboarding badge idiom:
-/// a tonal circular badge with an icon above a bold title.
+/// Shrink-wraps in slivers and scrolls within bounded viewports.
class GeneralEmptyState extends StatelessWidget {
const GeneralEmptyState({
super.key,
required this.icon,
required this.title,
+ this.actions = const [],
+ this.compact = false,
});
final IconData icon;
final String title;
+ final List<Widget> actions;
+ final bool compact;
@override
Widget build(BuildContext context) {
- final colorScheme = Theme.of(context).colorScheme;
- final textTheme = Theme.of(context).textTheme;
+ final theme = Theme.of(context);
+ final colorScheme = theme.colorScheme;
+ final textTheme = theme.textTheme;
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: 64,
- height: 64,
- decoration: BoxDecoration(
- color: colorScheme.secondaryContainer,
- shape: BoxShape.circle,
+ return Center(
+ child: SingleChildScrollView(
+ primary: false,
+ padding: compact
+ ? const EdgeInsets.all(16)
+ : const EdgeInsets.symmetric(horizontal: 24, vertical: 40),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 440),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ StateIconBadge(
+ icon: icon,
+ size: compact ? 56 : 88,
+ iconSize: compact ? 28 : 36,
+ backgroundColor: colorScheme.secondaryContainer,
+ foregroundColor: colorScheme.onSecondaryContainer,
+ ),
+ SizedBox(height: compact ? 16 : 24),
+ Semantics(
+ header: true,
+ liveRegion: true,
+ child: Text(
+ title,
+ textAlign: TextAlign.center,
+ style:
+ (compact ? textTheme.titleMedium : textTheme.titleLarge)
+ ?.copyWith(
+ color: colorScheme.onSurface,
+ fontWeight: FontWeight.w700,
+ ),
+ ),
+ ),
+ if (actions.isNotEmpty) ...[
+ SizedBox(height: compact ? 16 : 24),
+ Wrap(
+ alignment: WrapAlignment.center,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ spacing: 8,
+ runSpacing: 8,
+ children: actions,
+ ),
+ ],
+ ],
),
- 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/bean/widget/error_widget.dart b/lib/bean/widget/error_widget.dart
index e29e7195..82496c66 100644
--- a/lib/bean/widget/error_widget.dart
+++ b/lib/bean/widget/error_widget.dart
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
-import 'package:material_new_shapes/material_new_shapes.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
/// Shrink-wraps in slivers and scrolls within bounded page or media surfaces.
class GeneralErrorWidget extends StatelessWidget {
@@ -28,7 +28,7 @@ class GeneralErrorWidget extends StatelessWidget {
final colors = theme.colorScheme;
final errorActions = [
if (onRetry != null)
- GeneralErrorButton(
+ StateActionButton(
onPressed: onRetry,
text: retryText,
icon: Icons.refresh_rounded,
@@ -45,19 +45,12 @@ class GeneralErrorWidget extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- ExcludeSemantics(
- child: ClipPath(
- clipper: const _ErrorShapeClipper(),
- child: ColoredBox(
- color: colors.errorContainer,
- child: SizedBox.square(
- dimension: compact ? 48 : 80,
- child: Icon(icon,
- size: compact ? 24 : 36,
- color: colors.onErrorContainer),
- ),
- ),
- ),
+ StateIconBadge(
+ icon: icon,
+ size: compact ? 48 : 80,
+ iconSize: compact ? 24 : 36,
+ backgroundColor: colors.errorContainer,
+ foregroundColor: colors.onErrorContainer,
),
SizedBox(height: compact ? 16 : 24),
Semantics(
@@ -106,60 +99,3 @@ class GeneralErrorWidget extends StatelessWidget {
);
}
}
-
-class _ErrorShapeClipper extends CustomClipper<Path> {
- const _ErrorShapeClipper();
-
- static final _path = MaterialShapes.cookie4Sided.toPath();
-
- @override
- Path getClip(Size size) => _path
- .transform(Matrix4.diagonal3Values(size.width, size.height, 1).storage);
-
- @override
- bool shouldReclip(_ErrorShapeClipper oldClipper) => false;
-}
-
-class GeneralErrorButton extends StatelessWidget {
- const GeneralErrorButton({
- super.key,
- required this.onPressed,
- required this.text,
- this.icon,
- }) : _tonal = false;
-
- const GeneralErrorButton.tonal({
- super.key,
- required this.onPressed,
- required this.text,
- this.icon,
- }) : _tonal = true;
-
- final VoidCallback? onPressed;
- final String text;
- final IconData? icon;
- final bool _tonal;
-
- @override
- Widget build(BuildContext context) {
- final style = ButtonStyle(
- minimumSize: const WidgetStatePropertyAll(Size(64, 48)),
- padding: const WidgetStatePropertyAll(
- EdgeInsets.symmetric(horizontal: 24, vertical: 12)),
- shape: WidgetStateProperty.resolveWith((states) => RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(
- states.contains(WidgetState.pressed) ? 16 : 28),
- )),
- animationDuration: MediaQuery.disableAnimationsOf(context)
- ? Duration.zero
- : const Duration(milliseconds: 200),
- );
- final button = _tonal ? FilledButton.tonalIcon : FilledButton.icon;
- return button(
- onPressed: onPressed,
- style: style,
- icon: icon == null ? null : Icon(icon, size: 20),
- label: Text(text, textAlign: TextAlign.center),
- );
- }
-}
diff --git a/lib/bean/widget/state_presentation.dart b/lib/bean/widget/state_presentation.dart
new file mode 100644
index 00000000..7a6b1b4a
--- /dev/null
+++ b/lib/bean/widget/state_presentation.dart
@@ -0,0 +1,90 @@
+import 'package:flutter/material.dart';
+import 'package:material_new_shapes/material_new_shapes.dart';
+
+class StateIconBadge extends StatelessWidget {
+ const StateIconBadge({
+ super.key,
+ required this.icon,
+ required this.size,
+ required this.iconSize,
+ required this.backgroundColor,
+ required this.foregroundColor,
+ });
+
+ final IconData icon;
+ final double size;
+ final double iconSize;
+ final Color backgroundColor;
+ final Color foregroundColor;
+
+ @override
+ Widget build(BuildContext context) => ExcludeSemantics(
+ child: ClipPath(
+ clipper: const _StateShapeClipper(),
+ child: ColoredBox(
+ color: backgroundColor,
+ child: SizedBox.square(
+ dimension: size,
+ child: Icon(icon, size: iconSize, color: foregroundColor),
+ ),
+ ),
+ ),
+ );
+}
+
+class _StateShapeClipper extends CustomClipper<Path> {
+ const _StateShapeClipper();
+
+ static final _path = MaterialShapes.cookie4Sided.toPath();
+
+ @override
+ Path getClip(Size size) => _path
+ .transform(Matrix4.diagonal3Values(size.width, size.height, 1).storage);
+
+ @override
+ bool shouldReclip(_StateShapeClipper oldClipper) => false;
+}
+
+class StateActionButton extends StatelessWidget {
+ const StateActionButton({
+ super.key,
+ required this.onPressed,
+ required this.text,
+ this.icon,
+ }) : _tonal = false;
+
+ const StateActionButton.tonal({
+ super.key,
+ required this.onPressed,
+ required this.text,
+ this.icon,
+ }) : _tonal = true;
+
+ final VoidCallback? onPressed;
+ final String text;
+ final IconData? icon;
+ final bool _tonal;
+
+ @override
+ Widget build(BuildContext context) {
+ final style = ButtonStyle(
+ minimumSize: const WidgetStatePropertyAll(Size(64, 48)),
+ padding: const WidgetStatePropertyAll(
+ EdgeInsets.symmetric(horizontal: 24, vertical: 12)),
+ shape: WidgetStateProperty.resolveWith((states) => RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(
+ states.contains(WidgetState.pressed) ? 16 : 28),
+ )),
+ animationDuration: MediaQuery.disableAnimationsOf(context)
+ ? Duration.zero
+ : const Duration(milliseconds: 200),
+ );
+ final button = _tonal ? FilledButton.tonalIcon : FilledButton.icon;
+ return button(
+ onPressed: onPressed,
+ style: style,
+ icon: icon == null ? null : Icon(icon, size: 20),
+ label: Text(text, textAlign: TextAlign.center),
+ );
+ }
+}
diff --git a/lib/pages/collect/collect_library_view.dart b/lib/pages/collect/collect_library_view.dart
index 4a233519..f1375aea 100644
--- a/lib/pages/collect/collect_library_view.dart
+++ b/lib/pages/collect/collect_library_view.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kazumi/bean/card/network_img_layer.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/modules/collect/collect_module.dart';
import 'package:kazumi/modules/collect/collect_type.dart';
@@ -497,8 +498,6 @@ class _CollectLibraryViewState extends State<CollectLibraryView> {
}
Widget _emptyState(int matchCount, {required CollectType? type}) {
- final theme = Theme.of(context);
- final colors = theme.colorScheme;
final searching = _query.trim().isNotEmpty;
final String title;
@@ -516,35 +515,9 @@ class _CollectLibraryViewState extends State<CollectLibraryView> {
_ => '还没有收藏的番剧',
};
}
- return Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 32),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: 88,
- height: 88,
- decoration: BoxDecoration(
- color: colors.secondaryContainer,
- borderRadius: BorderRadius.circular(32),
- ),
- child: Icon(
- searching
- ? Icons.search_off_rounded
- : Icons.video_library_outlined,
- size: 36,
- color: colors.onSecondaryContainer,
- ),
- ),
- const SizedBox(height: 24),
- Text(title,
- textAlign: TextAlign.center,
- style: theme.textTheme.titleLarge
- ?.copyWith(fontWeight: FontWeight.w700)),
- ],
- ),
- ),
+ return GeneralEmptyState(
+ icon: searching ? Icons.search_off_rounded : Icons.video_library_outlined,
+ title: title,
);
}
}
diff --git a/lib/pages/download/download_page.dart b/lib/pages/download/download_page.dart
index 52ba69c7..dac68321 100644
--- a/lib/pages/download/download_page.dart
+++ b/lib/pages/download/download_page.dart
@@ -26,8 +26,7 @@ class DownloadPage extends StatefulWidget {
class _DownloadPageState extends State<DownloadPage> {
DownloadController get downloadController => widget.controller;
- /// Expansion state per record key. Kept outside the record snapshots
- /// because the controller replaces them on every refresh tick.
+ // Keep expansion state across controller snapshot replacements.
final Map<String, bool> _expanded = {};
@override
@@ -50,15 +49,11 @@ class _DownloadPageState extends State<DownloadPage> {
appBar: const SysAppBar(title: Text('下载管理')),
body: Observer(builder: (context) {
final recordKeys = downloadController.recordKeys.toList();
- // Drop expansion state for deleted records, so a re-downloaded
- // bangumi gets a fresh default instead of a stale cached one.
_expanded.removeWhere((key, _) => !recordKeys.contains(key));
if (recordKeys.isEmpty) {
- return const Center(
- child: GeneralEmptyState(
- icon: Icons.download_rounded,
- title: '暂无下载内容',
- ),
+ return const GeneralEmptyState(
+ icon: Icons.download_rounded,
+ title: '还没有下载记录',
);
}
return ListView.builder(
@@ -210,8 +205,7 @@ class _DownloadPageState extends State<DownloadPage> {
break;
case DownloadStatus.pending:
buttons.add(IconButton(
- icon: Icon(Icons.priority_high,
- size: 20, color: colorScheme.primary),
+ icon: Icon(Icons.priority_high, size: 20, color: colorScheme.primary),
onPressed: () {
downloadController.priorityDownload(
bangumiId: record.bangumiId,
diff --git a/lib/pages/error/storage_error_page.dart b/lib/pages/error/storage_error_page.dart
index 16405f5c..ba74928a 100644
--- a/lib/pages/error/storage_error_page.dart
+++ b/lib/pages/error/storage_error_page.dart
@@ -5,6 +5,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
class StorageErrorPage extends StatelessWidget {
const StorageErrorPage({super.key});
@@ -25,7 +26,7 @@ class StorageErrorPage extends StatelessWidget {
icon: Icons.storage_rounded,
errMsg: '当前存储位置:\n$path\n\n可在退出后删除该目录以重置本地存储,此操作会清除本地数据。',
actions: [
- GeneralErrorButton(
+ StateActionButton(
onPressed: () {
exit(0);
},
diff --git a/lib/pages/history/history_list_view.dart b/lib/pages/history/history_list_view.dart
index 9f4cbfc0..bfe2f7a1 100644
--- a/lib/pages/history/history_list_view.dart
+++ b/lib/pages/history/history_list_view.dart
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/history/history_module.dart';
import 'package:kazumi/pages/history/history_list_query.dart';
@@ -96,13 +98,13 @@ class _HistoryListViewState extends State<HistoryListView> {
ScrollConfiguration.of(context).copyWith(scrollbars: false),
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
slivers: [
- SliverPadding(
- padding: EdgeInsets.fromLTRB(inset, 16, inset, 0),
- sliver: SliverToBoxAdapter(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (widget.entries.isNotEmpty || filtered) ...[
+ if (widget.entries.isNotEmpty || filtered)
+ SliverPadding(
+ padding: EdgeInsets.fromLTRB(inset, 16, inset, 0),
+ sliver: SliverToBoxAdapter(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
TextField(
controller: _searchController,
focusNode: _searchFocus,
@@ -156,10 +158,9 @@ class _HistoryListViewState extends State<HistoryListView> {
),
),
],
- ],
+ ),
),
),
- ),
if (groups.isEmpty)
SliverFillRemaining(
hasScrollBody: false,
@@ -212,10 +213,11 @@ class _HistoryListViewState extends State<HistoryListView> {
),
),
],
- SliverPadding(
- padding: EdgeInsets.only(
- bottom: 24 + MediaQuery.paddingOf(context).bottom),
- ),
+ if (groups.isNotEmpty)
+ SliverPadding(
+ padding: EdgeInsets.only(
+ bottom: 24 + MediaQuery.paddingOf(context).bottom),
+ ),
],
),
);
@@ -280,49 +282,16 @@ class _HistoryListViewState extends State<HistoryListView> {
}
Widget _emptyState(bool filtered) {
- final theme = Theme.of(context);
- final colors = theme.colorScheme;
- return Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 40),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: 88,
- height: 88,
- decoration: BoxDecoration(
- color: colors.secondaryContainer,
- borderRadius: BorderRadius.circular(32),
- ),
- child: Icon(
- filtered ? Icons.search_off_rounded : Icons.history_rounded,
- size: 36,
- color: colors.onSecondaryContainer,
- ),
- ),
- const SizedBox(height: 24),
- Text(filtered ? '没有找到相关记录' : '还没有观看记录',
- textAlign: TextAlign.center,
- style: theme.textTheme.titleLarge
- ?.copyWith(fontWeight: FontWeight.w700)),
- const SizedBox(height: 8),
- Text(
- filtered ? '试试其他关键词,或查看全部记录' : '看过的番剧会留在这里,随时接着看',
- textAlign: TextAlign.center,
- style: theme.textTheme.bodyMedium
- ?.copyWith(color: colors.onSurfaceVariant),
- ),
- if (filtered) ...[
- const SizedBox(height: 20),
- FilledButton.tonal(
- onPressed: _resetFilters,
- child: const Text('查看全部记录'),
- ),
- ],
- ],
- ),
- ),
+ return GeneralEmptyState(
+ icon: filtered ? Icons.search_off_rounded : Icons.history_rounded,
+ title: filtered ? '没有找到相关记录' : '还没有观看记录',
+ actions: [
+ if (filtered)
+ StateActionButton.tonal(
+ onPressed: _resetFilters,
+ text: '查看全部记录',
+ ),
+ ],
);
}
}
diff --git a/lib/pages/info/character_info_view.dart b/lib/pages/info/character_info_view.dart
index 9599011e..f3fc2b7b 100644
--- a/lib/pages/info/character_info_view.dart
+++ b/lib/pages/info/character_info_view.dart
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';
import 'package:kazumi/bean/widget/content_section.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/image_preview.dart';
import 'package:kazumi/bean/widget/tonal_card.dart';
import 'package:kazumi/modules/character/character_full_item.dart';
@@ -183,12 +184,12 @@ class CharacterInfoView extends StatelessWidget {
character.unstructuredInfo.isEmpty &&
character.summary.isEmpty) ...[
const SizedBox(height: 24),
- TonalCard(
- padding: const EdgeInsets.all(20),
- child: Text('这个人物还没有补充资料',
- style: theme.textTheme.bodyMedium?.copyWith(
- color: theme.colorScheme.onSurfaceVariant,
- )),
+ const TonalCard(
+ child: GeneralEmptyState(
+ icon: Icons.person_outline_rounded,
+ title: '暂无人物资料',
+ compact: true,
+ ),
),
],
],
@@ -229,10 +230,14 @@ class _CharacterPortrait extends StatelessWidget {
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
if (imageUrl.isEmpty) {
- return TonalCard(
+ return const TonalCard(
child: SizedBox(
height: 160,
- child: _imageMessage(context, Icons.person_outline_rounded, '暂无人物图片'),
+ child: GeneralEmptyState(
+ icon: Icons.person_outline_rounded,
+ title: '暂无人物图片',
+ compact: true,
+ ),
),
);
}
diff --git a/lib/pages/info/character_page.dart b/lib/pages/info/character_page.dart
index ceb3b216..33b11238 100644
--- a/lib/pages/info/character_page.dart
+++ b/lib/pages/info/character_page.dart
@@ -1,6 +1,7 @@
import 'dart:ui';
import 'package:flutter/material.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:kazumi/bean/card/user_comments_card.dart';
@@ -177,8 +178,10 @@ class _CharacterPageState extends State<CharacterPage> {
}
if (_comments.isEmpty) {
return const SliverFillRemaining(
- child: Center(
- child: Text('什么都没有找到 (´;ω;`)'),
+ hasScrollBody: false,
+ child: GeneralEmptyState(
+ icon: Icons.chat_bubble_outline_rounded,
+ title: '还没有评论',
),
);
}
diff --git a/lib/pages/info/info_tabview.dart b/lib/pages/info/info_tabview.dart
index f3a88084..88e5e064 100644
--- a/lib/pages/info/info_tabview.dart
+++ b/lib/pages/info/info_tabview.dart
@@ -2,6 +2,7 @@ import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/card/comments_card.dart';
import 'package:kazumi/bean/card/character_card.dart';
import 'package:kazumi/bean/card/staff_card.dart';
@@ -230,7 +231,10 @@ class _InfoTabViewState extends State<InfoTabView> {
if (widget.relationsHasLoaded && widget.relationList.isEmpty) {
return const SliverFillRemaining(
hasScrollBody: false,
- child: Center(child: Text('暂无关联条目')),
+ child: GeneralEmptyState(
+ icon: Icons.account_tree_rounded,
+ title: '暂无关联条目',
+ ),
);
}
@@ -432,8 +436,10 @@ class _InfoTabViewState extends State<InfoTabView> {
}
if (widget.commentsIsEmpty) {
return const SliverFillRemaining(
- child: Center(
- child: Text('什么都没有找到 (´;ω;`)'),
+ hasScrollBody: false,
+ child: GeneralEmptyState(
+ icon: Icons.chat_bubble_outline_rounded,
+ title: '还没有评论',
),
);
}
@@ -509,8 +515,10 @@ class _InfoTabViewState extends State<InfoTabView> {
}
if (widget.staffIsEmpty) {
return const SliverFillRemaining(
- child: Center(
- child: Text('什么都没有找到 (´;ω;`)'),
+ hasScrollBody: false,
+ child: GeneralEmptyState(
+ icon: Icons.groups_rounded,
+ title: '暂无制作人员信息',
),
);
}
@@ -585,8 +593,10 @@ class _InfoTabViewState extends State<InfoTabView> {
}
if (widget.charactersIsEmpty) {
return const SliverFillRemaining(
- child: Center(
- child: Text('什么都没有找到 (´;ω;`)'),
+ hasScrollBody: false,
+ child: GeneralEmptyState(
+ icon: Icons.people_alt_rounded,
+ title: '暂无角色信息',
),
);
}
diff --git a/lib/pages/info/source_sheet.dart b/lib/pages/info/source_sheet.dart
index cd2d36a8..9dad3a24 100644
--- a/lib/pages/info/source_sheet.dart
+++ b/lib/pages/info/source_sheet.dart
@@ -9,7 +9,9 @@ import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/split_list_row.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/search/plugin_search_module.dart';
import 'package:kazumi/pages/collect/collect_controller.dart';
import 'package:kazumi/pages/info/info_controller.dart';
diff --git a/lib/pages/info/source_sheet_view.dart b/lib/pages/info/source_sheet_view.dart
index efa11e82..1fb60870 100644
--- a/lib/pages/info/source_sheet_view.dart
+++ b/lib/pages/info/source_sheet_view.dart
@@ -143,7 +143,12 @@ class _SourceSheetViewState extends State<_SourceSheetView> {
controller: _scrollController,
slivers: [
if (widget.groups.isEmpty)
- SliverToBoxAdapter(child: _buildNoSources())
+ const SliverToBoxAdapter(
+ child: GeneralEmptyState(
+ icon: Icons.extension_rounded,
+ title: '请先在规则管理中添加来源',
+ ),
+ )
else
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 24),
@@ -272,7 +277,30 @@ class _SourceSheetViewState extends State<_SourceSheetView> {
return SplitListRow(
topRadius: splitListOuterRadius,
bottomRadius: splitListOuterRadius,
- child: group.isSearching ? _buildSearching() : _buildRecovery(group),
+ child: switch (group.status) {
+ PluginSearchStatus.pending => _buildSearching(),
+ PluginSearchStatus.success ||
+ PluginSearchStatus.noResult =>
+ GeneralEmptyState(
+ icon: Icons.search_off_rounded,
+ title: '没有找到匹配结果',
+ compact: true,
+ actions: [
+ StateActionButton.tonal(
+ onPressed: () => widget.onSourceSearch(group.name),
+ text: '修改检索词',
+ ),
+ TextButton(
+ onPressed: () => widget.onSourceAliasSearch(group.name),
+ child: const Text('使用别名'),
+ ),
+ ],
+ ),
+ PluginSearchStatus.captcha =>
+ _buildSourceIssue(group.name, requiresVerification: true),
+ PluginSearchStatus.error =>
+ _buildSourceIssue(group.name, requiresVerification: false),
+ },
);
}
@@ -406,39 +434,25 @@ class _SourceSheetViewState extends State<_SourceSheetView> {
),
);
- Widget _buildRecovery(_SourceSearchGroup group) {
+ Widget _buildSourceIssue(String sourceName,
+ {required bool requiresVerification}) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
- final (icon, title, hint, action, onAction, alternative, onAlternative) =
- switch (group.status) {
- PluginSearchStatus.captcha => (
- Icons.verified_user_outlined,
- '需要验证',
- '完成网站验证后继续检索。',
- '进行验证',
- () => widget.onVerify(group.name),
- '打开网站',
- () => widget.onOpenBrowser(group.name),
- ),
- PluginSearchStatus.error => (
- Icons.error_outline_rounded,
- '检索失败',
- '可以重试,或打开网站检查是否可用。',
- '重试',
- () => widget.onRetry(group.name),
- '打开网站',
- () => widget.onOpenBrowser(group.name),
- ),
- _ => (
- Icons.search_off_rounded,
- '没有匹配结果',
- '试试别名或更短的关键词。',
- '修改检索词',
- () => widget.onSourceSearch(group.name),
- '使用别名',
- () => widget.onSourceAliasSearch(group.name),
- ),
- };
+ final (icon, title, hint, action, onAction) = requiresVerification
+ ? (
+ Icons.verified_user_outlined,
+ '需要验证',
+ '完成网站验证后继续检索。',
+ '进行验证',
+ () => widget.onVerify(sourceName),
+ )
+ : (
+ Icons.error_outline_rounded,
+ '检索失败',
+ '可以重试,或打开网站检查是否可用。',
+ '重试',
+ () => widget.onRetry(sourceName),
+ );
return Padding(
padding: const EdgeInsets.fromLTRB(16, 14, 16, 8),
child: Column(
@@ -452,9 +466,9 @@ class _SourceSheetViewState extends State<_SourceSheetView> {
child: Icon(
icon,
size: 20,
- color: group.status == PluginSearchStatus.error
- ? colors.error
- : colors.onSurfaceVariant,
+ color: requiresVerification
+ ? colors.onSurfaceVariant
+ : colors.error,
),
),
const SizedBox(width: 10),
@@ -482,28 +496,14 @@ class _SourceSheetViewState extends State<_SourceSheetView> {
runSpacing: 4,
children: [
FilledButton.tonal(onPressed: onAction, child: Text(action)),
- TextButton(onPressed: onAlternative, child: Text(alternative)),
+ TextButton(
+ onPressed: () => widget.onOpenBrowser(sourceName),
+ child: const Text('打开网站'),
+ ),
],
),
],
),
);
}
-
- Widget _buildNoSources() => Padding(
- padding: const EdgeInsets.fromLTRB(24, 32, 24, 24),
- child: Column(
- children: [
- Text('还没有来源规则', style: Theme.of(context).textTheme.titleMedium),
- const SizedBox(height: 8),
- Text(
- '请先在「规则管理」中添加来源,再开始播放。',
- textAlign: TextAlign.center,
- style: Theme.of(context).textTheme.bodyMedium?.copyWith(
- color: Theme.of(context).colorScheme.onSurfaceVariant,
- ),
- ),
- ],
- ),
- );
}
diff --git a/lib/pages/logs/logs_page.dart b/lib/pages/logs/logs_page.dart
index de5cb4aa..900f6b94 100644
--- a/lib/pages/logs/logs_page.dart
+++ b/lib/pages/logs/logs_page.dart
@@ -186,11 +186,9 @@ class _LogsPageState extends State<LogsPage> {
}
if (_logLines.isEmpty) {
- return const Center(
- child: GeneralEmptyState(
- icon: Icons.receipt_long_rounded,
- title: '暂无日志',
- ),
+ return const GeneralEmptyState(
+ icon: Icons.receipt_long_rounded,
+ title: '还没有日志记录',
);
}
diff --git a/lib/pages/player/episode_comments_view.dart b/lib/pages/player/episode_comments_view.dart
index b052f7af..1c259533 100644
--- a/lib/pages/player/episode_comments_view.dart
+++ b/lib/pages/player/episode_comments_view.dart
@@ -3,7 +3,9 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:kazumi/bean/card/user_comments_card.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/bangumi/episode_item.dart';
import 'package:kazumi/modules/comments/comment_item.dart';
@@ -77,7 +79,17 @@ class EpisodeCommentsView extends StatelessWidget {
)
else if (!isLoading && comments.isEmpty)
SliverToBoxAdapter(
- child: _EmptyDiscussion(onSelectEpisode: onSelectEpisode),
+ child: GeneralEmptyState(
+ icon: Icons.chat_bubble_outline_rounded,
+ title: '本集还没有讨论',
+ actions: [
+ StateActionButton.tonal(
+ onPressed: onSelectEpisode,
+ icon: Icons.video_library_outlined,
+ text: '切换分集',
+ ),
+ ],
+ ),
)
else if (comments.isNotEmpty) ...[
if (hasError)
@@ -316,47 +328,3 @@ class _EpisodeHeader extends StatelessWidget {
);
}
}
-
-class _EmptyDiscussion extends StatelessWidget {
- const _EmptyDiscussion({required this.onSelectEpisode});
-
- final VoidCallback onSelectEpisode;
-
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).colorScheme;
- final type = Theme.of(context).textTheme;
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 32),
- child: Column(children: [
- Container(
- width: 80,
- height: 80,
- decoration: BoxDecoration(
- color: colors.secondaryContainer,
- borderRadius: BorderRadius.circular(28),
- ),
- child: Center(
- child: Icon(Icons.chat_bubble_outline_rounded,
- size: 32, color: colors.onSecondaryContainer),
- ),
- ),
- const SizedBox(height: 20),
- Text('本集还没有讨论',
- textAlign: TextAlign.center,
- style: type.titleMedium?.copyWith(fontWeight: FontWeight.w700)),
- const SizedBox(height: 8),
- Text('换一集看看,或稍后回来刷新。',
- textAlign: TextAlign.center,
- style: type.bodyMedium
- ?.copyWith(color: colors.onSurfaceVariant, height: 1.6)),
- const SizedBox(height: 20),
- FilledButton.tonalIcon(
- onPressed: onSelectEpisode,
- icon: const Icon(Icons.video_library_outlined, size: 20),
- label: const Text('切换分集'),
- ),
- ]),
- );
- }
-}
diff --git a/lib/pages/player/video_details_sheet.dart b/lib/pages/player/video_details_sheet.dart
index ab5e9bb4..a921c53f 100644
--- a/lib/pages/player/video_details_sheet.dart
+++ b/lib/pages/player/video_details_sheet.dart
@@ -7,6 +7,7 @@ import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';
import 'package:kazumi/bean/widget/connected_tabs.dart';
import 'package:kazumi/bean/widget/content_section.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/tonal_card.dart';
import 'package:kazumi/pages/player/player_controller.dart';
@@ -250,8 +251,11 @@ class _VideoDetailsSheetState extends State<_VideoDetailsSheet>
Expanded(
child: TonalCard(
child: logs.isEmpty
- ? Center(
- child: Text('暂无运行日志', style: theme.textTheme.bodyMedium))
+ ? const GeneralEmptyState(
+ icon: Icons.receipt_long_rounded,
+ title: '还没有运行日志',
+ compact: true,
+ )
: ListView.builder(
key: const PageStorageKey('videoDetailsLogList'),
controller: _logScrollController,
diff --git a/lib/pages/plugin_editor/plugin_catalog_view.dart b/lib/pages/plugin_editor/plugin_catalog_view.dart
index 2373c2f5..09b9b93f 100644
--- a/lib/pages/plugin_editor/plugin_catalog_view.dart
+++ b/lib/pages/plugin_editor/plugin_catalog_view.dart
@@ -5,7 +5,9 @@ import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:kazumi/bean/card/rule_card.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/plugin/plugin_http_module.dart';
import 'package:kazumi/pages/plugin_editor/plugin_update_actions.dart';
import 'package:kazumi/pages/plugin_editor/rule_management_widgets.dart';
@@ -245,7 +247,7 @@ class _PluginCatalogViewState extends State<PluginCatalogView> {
onRetry: _refresh,
retryText: '重新加载',
actions: [
- GeneralErrorButton.tonal(
+ StateActionButton.tonal(
onPressed: _toggleGitProxyAndRefresh,
icon: Icons.tune_rounded,
text: enabled ? '关闭规则镜像' : '启用规则镜像',
@@ -253,11 +255,11 @@ class _PluginCatalogViewState extends State<PluginCatalogView> {
],
);
}
- return RuleEmptyState(
- title: _controller.pluginHTTPList.isEmpty ? '仓库暂时没有规则' : '没有符合条件的规则',
- description:
- _controller.pluginHTTPList.isEmpty ? '稍后刷新再来看看。' : '试试其他关键词,或切换筛选。',
- icon: Icons.search_off_rounded,
+ return GeneralEmptyState(
+ title: _controller.pluginHTTPList.isEmpty ? '仓库暂无规则' : '没有符合条件的规则',
+ icon: _controller.pluginHTTPList.isEmpty
+ ? Icons.extension_rounded
+ : Icons.search_off_rounded,
);
}
diff --git a/lib/pages/plugin_editor/plugin_view_page.dart b/lib/pages/plugin_editor/plugin_view_page.dart
index 4abc42fc..6795ba3f 100644
--- a/lib/pages/plugin_editor/plugin_view_page.dart
+++ b/lib/pages/plugin_editor/plugin_view_page.dart
@@ -11,6 +11,8 @@ import 'package:kazumi/bean/card/rule_card.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/pages/plugin_editor/plugin_update_actions.dart';
import 'package:kazumi/pages/plugin_editor/rule_dialogs.dart';
import 'package:kazumi/pages/plugin_editor/rule_management_widgets.dart';
@@ -342,26 +344,30 @@ class _PluginViewPageState extends State<PluginViewPage> {
],
),
footer: visible.isEmpty
- ? RuleEmptyState(
- title: all.isEmpty ? '从第一条规则开始' : '没有符合条件的规则',
- description: all.isEmpty
- ? '前往规则仓库,添加一个喜欢的番剧来源。'
+ ? GeneralEmptyState(
+ icon: all.isEmpty
+ ? Icons.extension_rounded
+ : Icons.search_off_rounded,
+ title: all.isEmpty
+ ? '还没有安装规则'
: _updatesOnly && query.isEmpty
- ? '当前没有可更新的规则。'
- : '试试其他名称,或清除筛选。',
- action: all.isEmpty
- ? FilledButton.tonalIcon(
+ ? '没有可更新的规则'
+ : '没有符合条件的规则',
+ actions: [
+ if (all.isEmpty)
+ StateActionButton.tonal(
onPressed: () => context
.pushNamed('/settings/plugin/shop'),
- icon: const Icon(
- Icons.travel_explore_rounded),
- label: const Text('浏览规则仓库'))
- : TextButton(
+ icon: Icons.travel_explore_rounded,
+ text: '浏览规则仓库')
+ else
+ StateActionButton.tonal(
onPressed: () => setState(() {
_search.clear();
_updatesOnly = false;
}),
- child: const Text('显示全部规则')),
+ text: '显示全部规则'),
+ ],
)
: null,
itemCount: visible.length,
diff --git a/lib/pages/plugin_editor/rule_management_widgets.dart b/lib/pages/plugin_editor/rule_management_widgets.dart
index 535e59e3..c4c97053 100644
--- a/lib/pages/plugin_editor/rule_management_widgets.dart
+++ b/lib/pages/plugin_editor/rule_management_widgets.dart
@@ -103,51 +103,6 @@ class RuleSection extends StatelessWidget {
}
}
-class RuleEmptyState extends StatelessWidget {
- const RuleEmptyState({
- super.key,
- required this.title,
- required this.description,
- this.icon = Icons.extension_outlined,
- this.action,
- });
-
- final String title;
- final String description;
- final IconData icon;
- final Widget? action;
-
- @override
- Widget build(BuildContext context) {
- final theme = Theme.of(context);
- return Center(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
- child: Column(mainAxisSize: MainAxisSize.min, children: [
- Container(
- padding: const EdgeInsets.all(20),
- decoration: BoxDecoration(
- color: theme.colorScheme.secondaryContainer,
- borderRadius: BorderRadius.circular(24),
- ),
- child: Icon(icon,
- size: 36, color: theme.colorScheme.onSecondaryContainer),
- ),
- const SizedBox(height: 20),
- Text(title,
- textAlign: TextAlign.center, style: theme.textTheme.titleLarge),
- const SizedBox(height: 8),
- Text(description,
- textAlign: TextAlign.center,
- style: theme.textTheme.bodyMedium
- ?.copyWith(color: theme.colorScheme.onSurfaceVariant)),
- if (action != null) ...[const SizedBox(height: 20), action!],
- ]),
- ),
- );
- }
-}
-
InputDecoration ruleInputDecoration(BuildContext context,
{String? label, String? hint, Widget? prefix, Widget? suffix}) {
final colors = Theme.of(context).colorScheme;
diff --git a/lib/pages/route_error_page.dart b/lib/pages/route_error_page.dart
index f71ec160..0e1b92f8 100644
--- a/lib/pages/route_error_page.dart
+++ b/lib/pages/route_error_page.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
class RouteErrorPage extends StatelessWidget {
const RouteErrorPage({
@@ -19,7 +20,7 @@ class RouteErrorPage extends StatelessWidget {
title: '无法打开页面',
errMsg: message,
actions: [
- GeneralErrorButton(
+ StateActionButton(
onPressed: () => context.navigate('/tab/popular/'),
icon: Icons.home_outlined,
text: '返回首页',
diff --git a/lib/pages/search/image_search_page.dart b/lib/pages/search/image_search_page.dart
index 821cf515..c56745dc 100644
--- a/lib/pages/search/image_search_page.dart
+++ b/lib/pages/search/image_search_page.dart
@@ -7,13 +7,14 @@ import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:image_picker/image_picker.dart';
-import 'package:material_new_shapes/material_new_shapes.dart';
import 'package:path/path.dart' as path;
import 'package:url_launcher/url_launcher.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/error_widget.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/search/image_search_module.dart';
import 'package:kazumi/pages/search/search_controller.dart';
diff --git a/lib/pages/search/image_search_widgets.dart b/lib/pages/search/image_search_widgets.dart
index a8990164..bbac76ea 100644
--- a/lib/pages/search/image_search_widgets.dart
+++ b/lib/pages/search/image_search_widgets.dart
@@ -79,29 +79,16 @@ class _ImageSearchEmblem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
- return ExcludeSemantics(
- child: ClipPath(
- clipper: const _SearchShapeClipper(),
- child: ColoredBox(
- color: colors.primaryContainer,
- child: SizedBox.square(
- dimension: size,
- child: Icon(Icons.image_search_rounded,
- size: size * .44, color: colors.onPrimaryContainer))),
- ));
+ return StateIconBadge(
+ icon: Icons.image_search_rounded,
+ size: size,
+ iconSize: size * .44,
+ backgroundColor: colors.primaryContainer,
+ foregroundColor: colors.onPrimaryContainer,
+ );
}
}
-class _SearchShapeClipper extends CustomClipper<Path> {
- const _SearchShapeClipper();
- static final _path = MaterialShapes.cookie4Sided.toPath();
- @override
- Path getClip(Size size) => _path
- .transform(Matrix4.diagonal3Values(size.width, size.height, 1).storage);
- @override
- bool shouldReclip(_SearchShapeClipper oldClipper) => false;
-}
-
class _ScreenshotTip extends StatelessWidget {
const _ScreenshotTip();
@@ -144,11 +131,7 @@ class _ImageSearchResults extends StatelessWidget {
final colors = Theme.of(context).colorScheme;
final type = Theme.of(context).textTheme;
if (searching) {
- return const _ResultStatus(
- icon: LoadingIndicator(size: 72, semanticsLabel: '正在匹配动画画面'),
- title: '正在寻找这一幕',
- description: '正在比对动画画面,匹配番名、集数与时间。\n请稍等片刻。',
- );
+ return const _ImageSearchLoadingState();
}
if (results.isEmpty) {
if (error != '未找到匹配结果') {
@@ -160,17 +143,17 @@ class _ImageSearchResults extends StatelessWidget {
retryText: '重新识别',
);
}
- return _ResultStatus(
- icon: Icon(Icons.image_not_supported_outlined,
- size: 48, color: colors.onSurfaceVariant),
- title: '还没找到这一幕',
- description: '试试同一场景的另一张截图,\n保留完整画面与原始比例。',
- action: onRetry == null
- ? null
- : FilledButton.tonalIcon(
- onPressed: onRetry,
- icon: const Icon(Icons.refresh_rounded),
- label: const Text('重新识别')),
+ return GeneralEmptyState(
+ icon: Icons.image_search_rounded,
+ title: '没有找到匹配画面',
+ actions: [
+ if (onRetry != null)
+ StateActionButton.tonal(
+ onPressed: onRetry!,
+ icon: Icons.refresh_rounded,
+ text: '重新识别',
+ ),
+ ],
);
}
return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
@@ -208,16 +191,8 @@ class _ImageSearchResults extends StatelessWidget {
}
}
-class _ResultStatus extends StatelessWidget {
- const _ResultStatus(
- {required this.icon,
- required this.title,
- required this.description,
- this.action});
- final Widget icon;
- final String title;
- final String description;
- final Widget? action;
+class _ImageSearchLoadingState extends StatelessWidget {
+ const _ImageSearchLoadingState();
@override
Widget build(BuildContext context) {
final type = Theme.of(context).textTheme;
@@ -226,18 +201,17 @@ class _ResultStatus extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 32),
child: Column(children: [
- icon,
+ const LoadingIndicator(size: 72, semanticsLabel: '正在匹配动画画面'),
const SizedBox(height: 24),
- Text(title,
+ Text('正在寻找这一幕',
textAlign: TextAlign.center,
style:
type.headlineSmall?.copyWith(fontWeight: FontWeight.w700)),
const SizedBox(height: 12),
- Text(description,
+ Text('正在比对动画画面,匹配番名、集数与时间。\n请稍等片刻。',
textAlign: TextAlign.center,
style: type.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant)),
- if (action != null) ...[const SizedBox(height: 24), action!],
]),
));
}
diff --git a/lib/pages/search/search_page.dart b/lib/pages/search/search_page.dart
index d694dffb..f37ac45f 100644
--- a/lib/pages/search/search_page.dart
+++ b/lib/pages/search/search_page.dart
@@ -9,6 +9,8 @@ import 'package:kazumi/bean/card/network_img_layer.dart';
import 'package:kazumi/bean/dialog/adaptive_bottom_sheet.dart';
import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/pages/search/search_controller.dart';
import 'package:kazumi/utils/constants.dart';
@@ -305,36 +307,26 @@ class _SearchPageState extends State<SearchPage> {
]),
)),
if (busy && allItems.isEmpty)
- const SliverToBoxAdapter(
- child: _SearchStatus(
- icon: Icons.search_rounded,
- title: '正在搜索番剧',
- message: '请稍候',
- loading: true))
+ const SliverToBoxAdapter(child: _SearchLoadingState())
else if (items.isEmpty)
SliverToBoxAdapter(
- child: _SearchStatus(
+ child: GeneralEmptyState(
icon: allItems.isEmpty
- ? Icons.travel_explore_rounded
+ ? Icons.search_off_rounded
: Icons.filter_alt_off_rounded,
title: allItems.isEmpty ? '没有找到番剧' : '这些番剧被筛选隐藏了',
- message: allItems.isEmpty
- ? (failed
- ? '没有找到结果,试试其他名称、放宽筛选,或重新搜索。'
- : '暂时没有匹配的番剧,可以继续加载或调整筛选。')
- : '可以显示已看和已弃作品,或继续加载更多番剧。',
actions: [
- FilledButton.tonalIcon(
+ StateActionButton.tonal(
onPressed: allItems.isEmpty
? () => _submit(_submittedQuery!)
: () async {
await _controller.setNotShowWatchedBangumis(false);
await _controller.setNotShowAbandonedBangumis(false);
},
- icon: Icon(allItems.isEmpty
+ icon: allItems.isEmpty
? Icons.refresh_rounded
- : Icons.visibility_outlined),
- label: Text(allItems.isEmpty ? '重新搜索' : '显示全部')),
+ : Icons.visibility_outlined,
+ text: allItems.isEmpty ? '重新搜索' : '显示全部'),
TextButton(onPressed: _showFilters, child: const Text('调整筛选')),
],
))
diff --git a/lib/pages/search/search_widgets.dart b/lib/pages/search/search_widgets.dart
index 69064b60..bb2f7185 100644
--- a/lib/pages/search/search_widgets.dart
+++ b/lib/pages/search/search_widgets.dart
@@ -130,19 +130,8 @@ class _SearchResultCard extends StatelessWidget {
}
}
-class _SearchStatus extends StatelessWidget {
- const _SearchStatus(
- {required this.icon,
- required this.title,
- required this.message,
- this.loading = false,
- this.actions = const []});
-
- final IconData icon;
- final String title;
- final String message;
- final bool loading;
- final List<Widget> actions;
+class _SearchLoadingState extends StatelessWidget {
+ const _SearchLoadingState();
@override
Widget build(BuildContext context) {
@@ -150,31 +139,13 @@ class _SearchStatus extends StatelessWidget {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 48, horizontal: 16),
child: Column(children: [
- if (loading)
- const LoadingIndicator(size: 40)
- else
- Icon(icon, size: 40, color: theme.colorScheme.onSurfaceVariant),
+ const LoadingIndicator(size: 40),
const SizedBox(height: 20),
Semantics(
liveRegion: true,
- child: Text(title,
+ child: Text('正在搜索番剧',
textAlign: TextAlign.center,
style: theme.textTheme.titleMedium)),
- const SizedBox(height: 8),
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 360),
- child: Text(message,
- textAlign: TextAlign.center,
- style: theme.textTheme.bodyMedium
- ?.copyWith(color: theme.colorScheme.onSurfaceVariant))),
- if (actions.isNotEmpty) ...[
- const SizedBox(height: 20),
- Wrap(
- spacing: 8,
- runSpacing: 8,
- alignment: WrapAlignment.center,
- children: actions),
- ],
]));
}
}
diff --git a/lib/pages/settings/danmaku/danmaku_shield_editor.dart b/lib/pages/settings/danmaku/danmaku_shield_editor.dart
index 2ecfd8b3..6521c2d1 100644
--- a/lib/pages/settings/danmaku/danmaku_shield_editor.dart
+++ b/lib/pages/settings/danmaku/danmaku_shield_editor.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:kazumi/bean/widget/content_section.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/pages/my/my_controller.dart';
class DanmakuShieldEditor extends StatefulWidget {
@@ -72,11 +73,10 @@ class _DanmakuShieldEditorState extends State<DanmakuShieldEditor> {
Observer(builder: (context) {
final rules = myController.shieldList.toList();
if (rules.isEmpty) {
- return Padding(
- padding: const EdgeInsets.all(24),
- child: Text('还没有屏蔽规则',
- textAlign: TextAlign.center,
- style: Theme.of(context).textTheme.bodyMedium),
+ return const GeneralEmptyState(
+ icon: Icons.filter_alt_off_rounded,
+ title: '还没有屏蔽规则',
+ compact: true,
);
}
return ContentSection.group(
diff --git a/lib/pages/timeline/timeline_page.dart b/lib/pages/timeline/timeline_page.dart
index 90295f29..287562cb 100644
--- a/lib/pages/timeline/timeline_page.dart
+++ b/lib/pages/timeline/timeline_page.dart
@@ -8,7 +8,9 @@ import 'package:kazumi/bean/dialog/adaptive_bottom_sheet.dart';
import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';
import 'package:kazumi/bean/widget/bangumi_mirror_error_widget.dart';
import 'package:kazumi/bean/widget/content_section.dart';
+import 'package:kazumi/bean/widget/empty_state_widget.dart';
import 'package:kazumi/bean/widget/loading_indicator.dart';
+import 'package:kazumi/bean/widget/state_presentation.dart';
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/pages/timeline/timeline_controller.dart';
import 'package:kazumi/services/storage/storage.dart';
@@ -366,8 +368,6 @@ class _TimelinePageState extends State<TimelinePage> {
required bool compact,
required bool loading,
}) {
- final theme = Theme.of(context);
- final colors = theme.colorScheme;
final cardHeight = BangumiTimelineCard.heightFor(
MediaQuery.textScalerOf(context),
compact: compact);
@@ -384,42 +384,21 @@ class _TimelinePageState extends State<TimelinePage> {
),
),
if (items.isEmpty)
- SliverToBoxAdapter(
+ SliverFillRemaining(
+ hasScrollBody: false,
child: Padding(
- padding: EdgeInsets.fromLTRB(inset + 16, 40, inset + 16, 40),
- child: Column(
- children: [
- Container(
- padding: const EdgeInsets.all(24),
- decoration: BoxDecoration(
- color: colors.secondaryContainer,
- borderRadius: BorderRadius.circular(28),
- ),
- child: Icon(
- filteredOut
- ? Icons.filter_alt_off_outlined
- : Icons.event_available_outlined,
- size: 32,
- color: colors.onSecondaryContainer,
+ padding: EdgeInsets.symmetric(horizontal: inset),
+ child: GeneralEmptyState(
+ icon: filteredOut
+ ? Icons.filter_alt_off_rounded
+ : Icons.event_available_rounded,
+ title: filteredOut ? '没有符合筛选的番剧' : '这一天暂无放送',
+ actions: [
+ if (filteredOut)
+ StateActionButton.tonal(
+ onPressed: _controller.clearFilters,
+ text: '清除筛选',
),
- ),
- const SizedBox(height: 20),
- Text(filteredOut ? '没有符合筛选的番剧' : '这一天暂无放送',
- textAlign: TextAlign.center,
- style: theme.textTheme.titleMedium),
- const SizedBox(height: 8),
- Text(
- filteredOut ? '调整筛选条件,看看其他作品吧' : '切换其他星期,发现更多番剧',
- textAlign: TextAlign.center,
- style: theme.textTheme.bodyMedium
- ?.copyWith(color: colors.onSurfaceVariant),
- ),
- if (filteredOut) ...[
- const SizedBox(height: 20),
- FilledButton.tonal(
- onPressed: _controller.clearFilters,
- child: const Text('清除筛选')),
- ],
],
),
),
diff --git a/lib/pages/video/episode_selection_panel.dart b/lib/pages/video/episode_selection_panel.dart
index 026d738e..3d94d84d 100644
--- a/lib/pages/video/episode_selection_panel.dart
+++ b/lib/pages/video/episode_selection_panel.dart
@@ -189,14 +189,9 @@ class EpisodeSelectionPanelState extends State<EpisodeSelectionPanel> {
if (count == 0)
const SliverFillRemaining(
hasScrollBody: false,
- child: Padding(
- padding: EdgeInsets.all(24),
- child: Center(
- child: GeneralEmptyState(
- icon: Icons.video_library_outlined,
- title: '这条线路暂无剧集',
- ),
- ),
+ child: GeneralEmptyState(
+ icon: Icons.video_library_outlined,
+ title: '这条线路暂无剧集',
),
)
else