基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
feat: redesign my page (#2408)
Predidit4cde64e200c7
diff --git a/lib/bean/card/bangumi_history_card.dart b/lib/bean/card/bangumi_history_card.dartindex 6beb91d7..e21a37b7 100644--- a/lib/bean/card/bangumi_history_card.dart+++ b/lib/bean/card/bangumi_history_card.dart@@ -4,55 +4,20 @@ import 'package:flutter_modular/flutter_modular.dart';import 'package:kazumi/bean/card/network_img_layer.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:kazumi/bean/widget/collect_button.dart';-import 'package:kazumi/modules/download/download_module.dart';import 'package:kazumi/modules/history/history_module.dart';import 'package:kazumi/pages/collect/collect_controller.dart';-import 'package:kazumi/pages/download/download_controller.dart';-import 'package:kazumi/pages/video/video_playback_args.dart';-import 'package:kazumi/plugins/plugins.dart';-import 'package:kazumi/plugins/plugins_controller.dart';+import 'package:kazumi/services/player/history_playback_service.dart';import 'package:kazumi/services/plugin/rule_engine_models.dart'show RuleCancelToken;-import 'package:kazumi/services/logging/logger.dart';import 'package:kazumi/utils/device.dart';import 'package:kazumi/utils/date_time.dart';-String historySourceText(String entryKind) {+String _historySourceText(String entryKind) {return HistoryEntryKind.normalize(entryKind) == HistoryEntryKind.offline? '缓存': '在线';}-Future<_HistoryPlaybackOpenResult> _openHistoryPlaybackForEntry({- required String entryKind,- required Future<VideoPlaybackArgs?> Function() openOnlinePlayback,- required Future<VideoPlaybackArgs?> Function() openOfflinePlayback,-}) async {- if (HistoryEntryKind.normalize(entryKind) == HistoryEntryKind.offline) {- final args = await openOfflinePlayback();- return _HistoryPlaybackOpenResult(- args: args,- failureMessage: args != null ? null : '未找到可用缓存',- );- }-- final args = await openOnlinePlayback();- return _HistoryPlaybackOpenResult(- args: args,- failureMessage: args != null ? null : '在线源不可用,请重新选择播放源',- );-}--class _HistoryPlaybackOpenResult {- const _HistoryPlaybackOpenResult({- required this.args,- required this.failureMessage,- });-- final VideoPlaybackArgs? args;- final String? failureMessage;-}-class BangumiHistoryCardV extends StatefulWidget {const BangumiHistoryCardV({super.key,@@ -70,9 +35,9 @@ class BangumiHistoryCardV extends StatefulWidget {}class _BangumiHistoryCardVState extends State<BangumiHistoryCardV> {- final PluginsController pluginsController = inject<PluginsController>();final CollectController collectController = inject<CollectController>();- final DownloadController downloadController = inject<DownloadController>();+ final HistoryPlaybackService _playbackService =+ inject<HistoryPlaybackService>();RuleCancelToken? _queryRoadsCancelToken;@@ -87,121 +52,26 @@ class _BangumiHistoryCardVState extends State<BangumiHistoryCardV> {KazumiDialog.showToast(message: '编辑模式');return;}+ _queryRoadsCancelToken?.cancel();+ final cancelToken = RuleCancelToken();+ _queryRoadsCancelToken = cancelToken;KazumiDialog.showLoading(msg: '获取中',barrierDismissible: isDesktop(),- onDismiss: () {- _queryRoadsCancelToken?.cancel();- },+ onDismiss: cancelToken.cancel,);- final result = await _openHistoryPlaybackForEntry(- entryKind: widget.historyItem.entryKind,- openOnlinePlayback: _openOnlinePlayback,- openOfflinePlayback: _openOfflinePlayback,+ final result = await _playbackService.open(+ widget.historyItem,+ cancelToken: cancelToken,);KazumiDialog.dismiss();if (!mounted) return;- final args = result.args;- if (args != null) {- context.pushNamed('/video/', arguments: args);- return;- }- KazumiDialog.showToast(message: result.failureMessage ?? '未找到可用播放入口');- }-- Future<VideoPlaybackArgs?> _openOnlinePlayback() async {- if (widget.historyItem.lastSrc.isEmpty) {- return null;- }- Plugin? targetPlugin;- for (Plugin plugin in pluginsController.pluginList) {- if (plugin.name == widget.historyItem.adapterName) {- targetPlugin = plugin;- break;- }- }- if (targetPlugin == null) {- return null;- }- try {- _queryRoadsCancelToken?.cancel();- _queryRoadsCancelToken = RuleCancelToken();- final roads = await targetPlugin.queryChapterRoads(- widget.historyItem.lastSrc,- cancelToken: _queryRoadsCancelToken,- );- if (roads.isEmpty) {- return null;- }- return OnlineVideoPlaybackArgs(- bangumiItem: widget.historyItem.bangumiItem,- plugin: targetPlugin,- title: widget.historyItem.bangumiItem.nameCn == ''- ? widget.historyItem.bangumiItem.name- : widget.historyItem.bangumiItem.nameCn,- src: widget.historyItem.lastSrc,- roads: roads,- );- } catch (_) {- KazumiLogger().w("QueryManager: failed to query roads");- return null;- }- }-- Future<VideoPlaybackArgs?> _openOfflinePlayback() async {- final downloadedEpisodes = downloadController.getCompletedEpisodes(- widget.historyItem.bangumiItem.id,- widget.historyItem.adapterName,- );- if (downloadedEpisodes.isEmpty) {- return null;- }-- DownloadEpisode? targetEpisode;- if (widget.historyItem.episodePageUrl.isNotEmpty) {- for (final episode in downloadedEpisodes) {- if (episode.episodePageUrl == widget.historyItem.episodePageUrl) {- targetEpisode = episode;- break;- }- }- }- targetEpisode ??= _episodeByNumber(- downloadedEpisodes,- widget.historyItem.lastWatchEpisode,- );- if (targetEpisode == null) {- return null;- }-- final localPath = downloadController.getLocalVideoPath(- widget.historyItem.bangumiItem.id,- widget.historyItem.adapterName,- targetEpisode.episodeNumber,- );- if (localPath == null) {- return null;- }-- return OfflineVideoPlaybackArgs(- bangumiItem: widget.historyItem.bangumiItem,- pluginName: widget.historyItem.adapterName,- episodeNumber: targetEpisode.episodeNumber,- road: targetEpisode.road,- downloadedEpisodes: downloadedEpisodes,- );- }-- DownloadEpisode? _episodeByNumber(- List<DownloadEpisode> episodes,- int episodeNumber,- ) {- for (final episode in episodes) {- if (episode.episodeNumber == episodeNumber) {- return episode;- }+ switch (result) {+ case HistoryPlaybackReady(:final args):+ context.pushNamed('/video/', arguments: args);+ case HistoryPlaybackUnavailable(:final reason):+ KazumiDialog.showToast(message: reason);}- return null;}@override@@ -216,7 +86,7 @@ class _BangumiHistoryCardVState extends State<BangumiHistoryCardV> {final String episodeText = widget.historyItem.lastWatchEpisodeName.isEmpty? '第${widget.historyItem.lastWatchEpisode}话': widget.historyItem.lastWatchEpisodeName;- final String sourceText = historySourceText(widget.historyItem.entryKind);+ final String sourceText = _historySourceText(widget.historyItem.entryKind);return Dismissible(key: ValueKey(widget.historyItem.key),diff --git a/lib/bean/card/bangumi_info_card.dart b/lib/bean/card/bangumi_info_card.dartindex 22d3dda8..e59579c3 100644--- a/lib/bean/card/bangumi_info_card.dart+++ b/lib/bean/card/bangumi_info_card.dart@@ -200,36 +200,36 @@ class _BangumiInfoCardVState extends State<BangumiInfoCardV> {),),if (!widget.isLoading)- Row(- children: [- Text(- widget.showRating- ? '${widget.bangumiItem.ratingScore}'- : '***',- style: TextStyle(- fontSize: 16,- fontWeight: FontWeight.bold,- color:- Theme.of(context).colorScheme.primary,- ),+ Row(+ children: [+ Text(+ widget.showRating+ ? '${widget.bangumiItem.ratingScore}'+ : '***',+ style: TextStyle(+ fontSize: 16,+ fontWeight: FontWeight.bold,+ color:+ Theme.of(context).colorScheme.primary,),- const SizedBox(width: 8),- RatingBarIndicator(- itemCount: 5,- rating: widget.showRating- ? widget.bangumiItem.ratingScore- .toDouble() /- 2- : 0,- itemBuilder: (context, index) => Icon(- Icons.star_rounded,- color:- Theme.of(context).colorScheme.primary,- ),- itemSize: 20.0,+ ),+ const SizedBox(width: 8),+ RatingBarIndicator(+ itemCount: 5,+ rating: widget.showRating+ ? widget.bangumiItem.ratingScore+ .toDouble() /+ 2+ : 0,+ itemBuilder: (context, index) => Icon(+ Icons.star_rounded,+ color:+ Theme.of(context).colorScheme.primary,),- ],- ),+ itemSize: 20.0,+ ),+ ],+ ),SizedBox(height: 8),Text('Bangumi Ranked:',diff --git a/lib/bean/card/comments_card.dart b/lib/bean/card/comments_card.dartindex 81f308a0..ba2ddfba 100644--- a/lib/bean/card/comments_card.dart+++ b/lib/bean/card/comments_card.dart@@ -83,15 +83,21 @@ class CommentsCard extends StatelessWidget {spacing: 5,children: [Text(commentItem!.user.nickname),- if(isOwn)+ if (isOwn)Container(- padding: const EdgeInsets.symmetric(horizontal: 2),+ padding:+ const EdgeInsets.symmetric(horizontal: 2),decoration: BoxDecoration(color: Theme.of(context).colorScheme.primary,borderRadius: BorderRadius.circular(4),),- child: Text('我的吐槽',- style: TextStyle(fontSize: 12,color: Theme.of(context).colorScheme.primaryContainer),+ child: Text(+ '我的吐槽',+ style: TextStyle(+ fontSize: 12,+ color: Theme.of(context)+ .colorScheme+ .primaryContainer),))],),diff --git a/lib/bean/settings/settings_detail_scaffold.dart b/lib/bean/settings/settings_detail_scaffold.dartnew file mode 100644index 00000000..160c5912--- /dev/null+++ b/lib/bean/settings/settings_detail_scaffold.dart@@ -0,0 +1,84 @@+import 'package:flutter/material.dart';+import 'package:kazumi/bean/appbar/sys_app_bar.dart';++/// Tells a settings detail page how the settings page is hosting it.+///+/// Pages opened with pushNamed sit above the Navigator and never see this+/// scope, so the same page also works as a standalone route.+class SettingsPaneScope extends InheritedWidget {+ const SettingsPaneScope({+ super.key,+ required this.embedded,+ this.onBack,+ required super.child,+ });++ /// Rendered as the right pane; the tab rail owns navigation.+ final bool embedded;++ /// Rendered as a single-pane detail; back returns to the category list.+ final VoidCallback? onBack;++ static SettingsPaneScope? of(BuildContext context) {+ return context.dependOnInheritedWidgetOfExactType<SettingsPaneScope>();+ }++ @override+ bool updateShouldNotify(SettingsPaneScope oldWidget) {+ return embedded != oldWidget.embedded || onBack != oldWidget.onBack;+ }+}++class SettingsDetailScaffold extends StatelessWidget {+ const SettingsDetailScaffold({+ super.key,+ required this.title,+ required this.body,+ this.actions,+ this.leading,+ });++ final Widget title;+ final Widget body;+ final List<Widget>? actions;+ final Widget? leading;++ @override+ Widget build(BuildContext context) {+ final scope = SettingsPaneScope.of(context);++ if (scope != null && scope.embedded) {+ return Scaffold(+ backgroundColor: Colors.transparent,+ appBar: AppBar(+ backgroundColor: Colors.transparent,+ scrolledUnderElevation: 0,+ automaticallyImplyLeading: false,+ toolbarHeight: 64,+ titleSpacing: leading == null ? 24 : NavigationToolbar.kMiddleSpacing,+ leading: leading,+ title: title,+ titleTextStyle: Theme.of(context).textTheme.headlineSmall,+ actions: actions,+ ),+ body: body,+ );+ }++ final onBack = scope?.onBack;+ return Scaffold(+ appBar: SysAppBar(+ title: title,+ actions: actions,+ leading: leading ??+ (onBack == null+ ? null+ : IconButton(+ onPressed: onBack,+ icon: const Icon(Icons.arrow_back),+ )),+ ),+ body: body,+ );+ }+}diff --git a/lib/bean/settings/settings_list.dart b/lib/bean/settings/settings_list.dartnew file mode 100644index 00000000..41e5123c--- /dev/null+++ b/lib/bean/settings/settings_list.dart@@ -0,0 +1,245 @@+import 'package:flutter/material.dart';++enum _TileKind { plain, toggle, radio }++class SettingsList extends StatelessWidget {+ const SettingsList({super.key, required this.sections, this.maxWidth});++ final List<Widget> sections;+ final double? maxWidth;++ @override+ Widget build(BuildContext context) {+ return ListView.builder(+ padding: const EdgeInsets.symmetric(vertical: 12),+ itemCount: sections.length,+ itemBuilder: (context, index) => Center(+ child: ConstrainedBox(+ constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),+ child: sections[index],+ ),+ ),+ );+ }+}++class SettingsSection extends StatelessWidget {+ const SettingsSection({+ super.key,+ required this.tiles,+ this.title,+ this.bottomInfo,+ this.margin,+ });++ final List<Widget> tiles;+ final Widget? title;+ final Widget? bottomInfo;+ final EdgeInsetsGeometry? margin;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ return Padding(+ padding: margin ?? const EdgeInsets.fromLTRB(16, 0, 16, 16),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (title != null)+ Padding(+ padding: const EdgeInsets.fromLTRB(4, 0, 4, 8),+ child: DefaultTextStyle.merge(+ style: textTheme.titleSmall+ ?.copyWith(color: colorScheme.onSurfaceVariant),+ child: title!,+ ),+ ),+ Material(+ // M3 elevated card token, minus the elevation: tone carries the+ // separation so the group never casts a shadow.+ color: colorScheme.surfaceContainerLow,+ borderRadius: BorderRadius.circular(16),+ clipBehavior: Clip.antiAlias,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: tiles,+ ),+ ),+ if (bottomInfo != null)+ Padding(+ padding: const EdgeInsets.fromLTRB(4, 8, 4, 0),+ child: DefaultTextStyle.merge(+ style: textTheme.bodySmall+ ?.copyWith(color: colorScheme.onSurfaceVariant),+ child: bottomInfo!,+ ),+ ),+ ],+ ),+ );+ }+}++/// A [SettingsSection] whose tiles form a single radio group, so arrow keys+/// traverse the options and screen readers announce them as one set.+class SettingsRadioSection<T> extends StatelessWidget {+ const SettingsRadioSection({+ super.key,+ required this.groupValue,+ required this.onChanged,+ required this.tiles,+ this.title,+ });++ final T? groupValue;+ final ValueChanged<T?> onChanged;+ final List<Widget> tiles;+ final Widget? title;++ @override+ Widget build(BuildContext context) {+ return RadioGroup<T>(+ groupValue: groupValue,+ onChanged: onChanged,+ child: SettingsSection(title: title, tiles: tiles),+ );+ }+}++class SettingsTile<T> extends StatelessWidget {+ const SettingsTile({+ super.key,+ required this.title,+ this.description,+ this.trailing,+ this.value,+ this.onPressed,+ this.enabled = true,+ }) : _kind = _TileKind.plain,+ onToggle = null,+ initialValue = null,+ radioValue = null;++ /// Tapping the row toggles too, in which case [onToggle] receives null.+ const SettingsTile.switchTile({+ super.key,+ required this.title,+ required this.initialValue,+ required this.onToggle,+ this.description,+ this.enabled = true,+ }) : _kind = _TileKind.toggle,+ trailing = null,+ value = null,+ onPressed = null,+ radioValue = null;++ /// Selection and change handling come from the enclosing+ /// [SettingsRadioSection], so the whole option list is one radio group.+ const SettingsTile.radioTile({+ super.key,+ required this.title,+ required T this.radioValue,+ this.description,+ this.enabled = true,+ }) : _kind = _TileKind.radio,+ trailing = null,+ value = null,+ onPressed = null,+ onToggle = null,+ initialValue = null;++ final Widget title;+ final Widget? description;+ final Widget? trailing;+ final Widget? value;+ final void Function(BuildContext context)? onPressed;+ final void Function(bool? value)? onToggle;+ final bool? initialValue;+ final T? radioValue;+ final bool enabled;+ final _TileKind _kind;++ VoidCallback? _tapHandler(BuildContext context) {+ if (!enabled) {+ return null;+ }+ switch (_kind) {+ case _TileKind.plain:+ return onPressed == null ? null : () => onPressed!(context);+ case _TileKind.toggle:+ return onToggle == null ? null : () => onToggle!(null);+ case _TileKind.radio:+ final registry = RadioGroup.maybeOf<T>(context);+ return registry == null ? null : () => registry.onChanged(radioValue);+ }+ }++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ final disabled = colorScheme.onSurface.withValues(alpha: 0.38);+ final foreground = enabled ? colorScheme.onSurface : disabled;+ final secondary = enabled ? colorScheme.onSurfaceVariant : disabled;++ return InkWell(+ onTap: _tapHandler(context),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: 32),+ child: Row(+ children: [+ Expanded(+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ DefaultTextStyle.merge(+ style: textTheme.bodyLarge?.copyWith(color: foreground),+ child: title,+ ),+ if (description != null) ...[+ const SizedBox(height: 2),+ DefaultTextStyle.merge(+ style: textTheme.bodySmall?.copyWith(color: secondary),+ child: description!,+ ),+ ],+ ],+ ),+ ),+ if (value != null) ...[+ const SizedBox(width: 12),+ DefaultTextStyle.merge(+ style: textTheme.bodyMedium?.copyWith(color: secondary),+ child: value!,+ ),+ ],+ if (trailing != null) ...[+ const SizedBox(width: 8),+ IconTheme.merge(+ data: IconThemeData(color: secondary),+ child: trailing!,+ ),+ ],+ if (_kind == _TileKind.toggle) ...[+ const SizedBox(width: 12),+ Switch(+ value: initialValue ?? false,+ onChanged: enabled ? onToggle : null,+ ),+ ],+ if (_kind == _TileKind.radio) ...[+ const SizedBox(width: 12),+ Radio<T>(value: radioValue as T, enabled: enabled),+ ],+ ],+ ),+ ),+ ),+ );+ }+}diff --git a/lib/core_module.dart b/lib/core_module.dartindex 264d2679..e478729b 100644--- a/lib/core_module.dart+++ b/lib/core_module.dart@@ -11,6 +11,7 @@ import 'package:kazumi/repositories/history_repository.dart';import 'package:kazumi/repositories/search_history_repository.dart';import 'package:kazumi/services/download/download_manager.dart';import 'package:kazumi/services/player/audio_controller.dart';+import 'package:kazumi/services/player/history_playback_service.dart';import 'package:kazumi/services/shaders/shader_asset_service.dart';/// Root-owned application data and cross-feature coordinators.@@ -30,6 +31,7 @@ final coreModule = createModule(// Service layer...addSingleton<IDownloadManager>(DownloadManager.new)..addSingleton<AudioController>(AudioController.new)+ ..addSingleton<HistoryPlaybackService>(HistoryPlaybackService.new)..addSingleton<ShaderAssetService>(ShaderAssetService.new)// Cross-feature state and coordinators...addSingleton<PluginsController>(PluginsController.new)diff --git a/lib/main.dart b/lib/main.dartindex 2ad8aff2..e8c489a7 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -97,7 +97,7 @@ void main() async {ModularApp(module: appModule,navigatorKey: rootNavigatorKey,- navigatorObservers: [KazumiDialog.observer],+ navigatorObservers: [KazumiDialog.observer, rootRouteObserver],defaultTransition: TransitionType.material,provide: (scoped) {scoped.addChangeNotifier<ThemeProvider>(ThemeProvider.new);diff --git a/lib/modules/my/recent_watch_item.dart b/lib/modules/my/recent_watch_item.dartnew file mode 100644index 00000000..35348f98--- /dev/null+++ b/lib/modules/my/recent_watch_item.dart@@ -0,0 +1,70 @@+import 'package:kazumi/modules/history/history_module.dart';++/// Display snapshot for a continue-watching card.+///+/// Cards read these fields only, so the sole way the list changes is+/// "history changed -> re-derive".+class RecentWatchItem {+ const RecentWatchItem({+ required this.id,+ required this.title,+ required this.coverUrl,+ required this.episodeLabel,+ required this.sourceLabel,+ required this.adapterName,+ required this.lastWatchTime,+ required this.history,+ });++ final String id;+ final String title;+ final String coverUrl;+ final String episodeLabel;+ final String sourceLabel;+ final String adapterName;+ final DateTime lastWatchTime;++ /// Handed back to the playback service; cards never read its fields.+ final History history;++ factory RecentWatchItem.from(History history) {+ final bangumiItem = history.bangumiItem;+ final isOffline = HistoryEntryKind.normalize(history.entryKind) ==+ HistoryEntryKind.offline;+ return RecentWatchItem(+ id: history.key,+ title: bangumiItem.nameCn.isEmpty ? bangumiItem.name : bangumiItem.nameCn,+ coverUrl: bangumiItem.images['large'] ?? '',+ episodeLabel: history.lastWatchEpisodeName.isEmpty+ ? '第${history.lastWatchEpisode}话'+ : history.lastWatchEpisodeName,+ sourceLabel: isOffline ? '缓存' : '在线',+ adapterName: history.adapterName,+ lastWatchTime: history.lastWatchTime,+ history: history,+ );+ }++ @override+ bool operator ==(Object other) {+ return other is RecentWatchItem &&+ other.id == id &&+ other.title == title &&+ other.coverUrl == coverUrl &&+ other.episodeLabel == episodeLabel &&+ other.sourceLabel == sourceLabel &&+ other.adapterName == adapterName &&+ other.lastWatchTime == lastWatchTime;+ }++ @override+ int get hashCode => Object.hash(+ id,+ title,+ coverUrl,+ episodeLabel,+ sourceLabel,+ adapterName,+ lastWatchTime,+ );+}diff --git a/lib/modules/my/watch_stats.dart b/lib/modules/my/watch_stats.dartnew file mode 100644index 00000000..7b288e96--- /dev/null+++ b/lib/modules/my/watch_stats.dart@@ -0,0 +1,115 @@+import 'package:flutter/foundation.dart' show mapEquals;+import 'package:kazumi/modules/bangumi/bangumi_item.dart';+import 'package:kazumi/modules/collect/collect_module.dart';+import 'package:kazumi/modules/collect/collect_type.dart';+import 'package:kazumi/modules/download/download_module.dart';+import 'package:kazumi/modules/history/history_module.dart';++/// Device-local viewing stats, derived from history, collect and download data.+class WatchStats {+ const WatchStats({+ this.collectedCount = 0,+ this.collectCounts = const {},+ this.watchedEpisodeCount = 0,+ this.watchedBangumiCount = 0,+ this.downloadTaskCount = 0,+ this.lastWatchTime,+ this.lastWatchName,+ });++ final int collectedCount;+ final Map<CollectType, int> collectCounts;+ final int watchedEpisodeCount;+ final int watchedBangumiCount;+ final int downloadTaskCount;+ final DateTime? lastWatchTime;+ final String? lastWatchName;++ /// Playback rewrites history every second, so equality lets the observable+ /// stay quiet unless a number actually moved.+ @override+ bool operator ==(Object other) {+ return other is WatchStats &&+ other.collectedCount == collectedCount &&+ mapEquals(other.collectCounts, collectCounts) &&+ other.watchedEpisodeCount == watchedEpisodeCount &&+ other.watchedBangumiCount == watchedBangumiCount &&+ other.downloadTaskCount == downloadTaskCount &&+ other.lastWatchTime == lastWatchTime &&+ other.lastWatchName == lastWatchName;+ }++ // collectCounts is covered by ==; leaving it out only widens buckets.+ @override+ int get hashCode => Object.hash(+ collectedCount,+ watchedEpisodeCount,+ watchedBangumiCount,+ downloadTaskCount,+ lastWatchTime,+ lastWatchName,+ );++ /// Episodes are keyed by bangumi and number, so watching one through several+ /// rules or both online and offline still counts once.+ factory WatchStats.from({+ required List<History> histories,+ required List<CollectedBangumi> collectibles,+ required List<DownloadRecord> downloadRecords,+ }) {+ final watchedEpisodeKeys = <String>{};+ final watchedBangumiIds = <int>{};+ History? lastWatched;++ for (final history in histories) {+ if (history.progresses.isEmpty) {+ continue;+ }+ final bangumiId = history.bangumiItem.id;+ watchedBangumiIds.add(bangumiId);+ if (lastWatched == null ||+ lastWatched.lastWatchTime.isBefore(history.lastWatchTime)) {+ lastWatched = history;+ }+ for (final episode in history.progresses.keys) {+ watchedEpisodeKeys.add('$bangumiId::$episode');+ }+ }++ var collectedCount = 0;+ final collectCounts = <CollectType, int>{};+ for (final collectible in collectibles) {+ final type = CollectType.fromValue(collectible.type);+ if (!type.isCollected) {+ continue;+ }+ collectedCount++;+ collectCounts[type] = (collectCounts[type] ?? 0) + 1;+ }++ // Every task counts, in flight or finished.+ var downloadTaskCount = 0;+ for (final record in downloadRecords) {+ downloadTaskCount += record.episodes.length;+ }++ return WatchStats(+ collectedCount: collectedCount,+ collectCounts: collectCounts,+ watchedEpisodeCount: watchedEpisodeKeys.length,+ watchedBangumiCount: watchedBangumiIds.length,+ downloadTaskCount: downloadTaskCount,+ lastWatchTime: lastWatched?.lastWatchTime,+ lastWatchName: lastWatched == null+ ? null+ : _displayName(lastWatched.bangumiItem),+ );+ }++ static String? _displayName(BangumiItem item) {+ if (item.nameCn.isNotEmpty) {+ return item.nameCn;+ }+ return item.name.isEmpty ? null : item.name;+ }+}diff --git a/lib/navigation.dart b/lib/navigation.dartindex d8b39bf0..14984132 100644--- a/lib/navigation.dart+++ b/lib/navigation.dart@@ -2,3 +2,9 @@ import 'package:flutter/material.dart';final rootNavigatorKey = GlobalKey<NavigatorState>();final rootScaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();++/// Lets [RouteAware] pages learn they were covered or revealed again.+///+/// Restricted to [PageRoute] on purpose: dialogs and bottom sheets are+/// PopupRoutes, and sitting under one does not make a page hidden.+final rootRouteObserver = RouteObserver<PageRoute<void>>();diff --git a/lib/pages/about/about_page.dart b/lib/pages/about/about_page.dartindex 5322bffd..8dae2dad 100644--- a/lib/pages/about/about_page.dart+++ b/lib/pages/about/about_page.dart@@ -1,9 +1,9 @@import 'dart:io';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';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/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:kazumi/pages/my/my_controller.dart';import 'package:kazumi/request/config/api_endpoints.dart';@@ -135,109 +135,98 @@ class _AboutPageState extends State<AboutPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: true,onPopInvokedWithResult: (bool didPop, Object? result) async {onBackPressed(context);},- child: Scaffold(- appBar: const SysAppBar(title: Text('关于')),- // backgroundColor: Colors.transparent,+ child: SettingsDetailScaffold(+ title: const Text('关于'),body: SettingsList(maxWidth: 1000,sections: [SettingsSection(tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {context.pushNamed('/settings/about/license');},- title:- Text('开源许可证', style: TextStyle(fontFamily: fontFamily)),- description: Text('查看所有开源许可证',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('开源许可证'),+ description: Text('查看所有开源许可证'),),],),SettingsSection(- title: Text('外部链接', style: TextStyle(fontFamily: fontFamily)),+ title: Text('外部链接'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse(ApiEndpoints.projectUrl),mode: LaunchMode.externalApplication);},- title: Text('项目主页', style: TextStyle(fontFamily: fontFamily)),+ title: Text('项目主页'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse(ApiEndpoints.sourceUrl),mode: LaunchMode.externalApplication);},- title: Text('代码仓库', style: TextStyle(fontFamily: fontFamily)),- value:- Text('Github', style: TextStyle(fontFamily: fontFamily)),+ title: Text('代码仓库'),+ value: Text('Github'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse(ApiEndpoints.iconUrl),mode: LaunchMode.externalApplication);},- title: Text('图标创作', style: TextStyle(fontFamily: fontFamily)),- value:- Text('Pixiv', style: TextStyle(fontFamily: fontFamily)),+ title: Text('图标创作'),+ value: Text('Pixiv'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse(ApiEndpoints.bangumiIndex),mode: LaunchMode.externalApplication);},- title: Text('番剧索引', style: TextStyle(fontFamily: fontFamily)),- value:- Text('Bangumi', style: TextStyle(fontFamily: fontFamily)),+ title: Text('番剧索引'),+ value: Text('Bangumi'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse('https://trace.moe'),mode: LaunchMode.externalApplication);},- title: Text('以图搜番', style: TextStyle(fontFamily: fontFamily)),- value: Text('trace.moe',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('以图搜番'),+ value: Text('trace.moe'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse(ApiEndpoints.dandanIndex),mode: LaunchMode.externalApplication);},- title: Text('弹幕来源', style: TextStyle(fontFamily: fontFamily)),- description: Text('ID: ${dandanCredentials['id']}',- style: TextStyle(fontFamily: fontFamily)),- value: Text('弹弹play开放平台',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕来源'),+ description: Text('ID: ${dandanCredentials['id']}'),+ value: Text('弹弹play开放平台'),),],),SettingsSection(- title: Text('社区', style: TextStyle(fontFamily: fontFamily)),+ title: Text('社区'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {launchUrl(Uri.parse(ApiEndpoints.telegramGroup),mode: LaunchMode.externalApplication);},- title: Text('Telegram',- style: TextStyle(fontFamily: fontFamily)),- value: Text('点击加入', style: TextStyle(fontFamily: fontFamily)),+ title: Text('Telegram'),+ value: Text('点击加入'),),],),if (isDesktop()) // 之后如果有非桌面平台的新选项可以移除SettingsSection(- title: Text('默认行为', style: TextStyle(fontFamily: fontFamily)),+ title: Text('默认行为'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {if (menuController.isOpen) {menuController.close();@@ -245,8 +234,7 @@ class _AboutPageState extends State<AboutPage> {menuController.open();}},- title:- Text('关闭时', style: TextStyle(fontFamily: fontFamily)),+ title: Text('关闭时'),value: MenuAnchor(consumeOutsideTap: true,controller: menuController,@@ -285,26 +273,25 @@ class _AboutPageState extends State<AboutPage> {),SettingsSection(tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {context.pushNamed('/settings/about/logs');},- title: Text('错误日志', style: TextStyle(fontFamily: fontFamily)),+ title: Text('错误日志'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {_showCacheDialog();},- title: Text('清除缓存', style: TextStyle(fontFamily: fontFamily)),+ title: Text('清除缓存'),value: _cacheSizeMB == -1- ? Text('统计中...', style: TextStyle(fontFamily: fontFamily))- : Text('${_cacheSizeMB.toStringAsFixed(2)}MB',- style: TextStyle(fontFamily: fontFamily)),+ ? Text('统计中...')+ : Text('${_cacheSizeMB.toStringAsFixed(2)}MB'),),],),SettingsSection(- title: Text('应用更新', style: TextStyle(fontFamily: fontFamily)),+ title: Text('应用更新'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -313,23 +300,20 @@ class _AboutPageState extends State<AboutPage> {SettingsKeys.autoUpdate, autoUpdate);setState(() {});},- title: Text('启动时检查应用更新',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('启动时检查应用更新'),initialValue: autoUpdate,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {myController.checkUpdate();},- title:- Text('检查应用更新', style: TextStyle(fontFamily: fontFamily)),- value: Text('当前版本 ${ApiEndpoints.version}',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('检查应用更新'),+ value: Text('当前版本 ${ApiEndpoints.version}'),),],),SettingsSection(- title: Text('规则更新', style: TextStyle(fontFamily: fontFamily)),+ title: Text('规则更新'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -341,8 +325,7 @@ class _AboutPageState extends State<AboutPage> {);setState(() {});},- title: Text('启动时检查规则更新',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('启动时检查规则更新'),initialValue: checkPluginUpdateOnStartup,),],diff --git a/lib/pages/bangumi/bangumi_setting.dart b/lib/pages/bangumi/bangumi_setting.dartindex a9b4f780..a74ddbe0 100644--- a/lib/pages/bangumi/bangumi_setting.dart+++ b/lib/pages/bangumi/bangumi_setting.dart@@ -1,4 +1,4 @@-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:flutter/material.dart';import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';@@ -93,7 +93,6 @@ class _BangumiEditorPageState extends State<BangumiEditorPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: !syncCollectiblesing,child: Scaffold(@@ -139,13 +138,11 @@ class _BangumiEditorPageState extends State<BangumiEditorPage> {setState(() {});}},- title: Text('即时同步提示',- style: TextStyle(fontFamily: fontFamily)),- description: Text('点击追番按钮触发即时同步时显示提示框',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('即时同步提示'),+ description: Text('点击追番按钮触发即时同步时显示提示框'),initialValue: bangumiImmediateSyncToastEnable,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {if (syncPriorityMenuController.isOpen) {syncPriorityMenuController.close();@@ -153,17 +150,14 @@ class _BangumiEditorPageState extends State<BangumiEditorPage> {syncPriorityMenuController.open();}},- title: Text('同步优先级',- style: TextStyle(fontFamily: fontFamily)),- description: Text('当本地与 Bangumi 状态不一致时优先使用哪个状态',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('同步优先级'),+ description: Text('当本地与 Bangumi 状态不一致时优先使用哪个状态'),value: MenuAnchor(consumeOutsideTap: true,controller: syncPriorityMenuController,builder: (context, controller, child) => Text(BangumiSyncPriority.fromValue(syncPriority)- .label,- style: TextStyle(fontFamily: fontFamily)),+ .label),menuChildren: [for (final entry in BangumiSyncPriority.values)MenuItemButton(@@ -184,7 +178,6 @@ class _BangumiEditorPageState extends State<BangumiEditorPage> {.colorScheme.primary: null,- fontFamily: fontFamily,),),)))@@ -202,10 +195,8 @@ class _BangumiEditorPageState extends State<BangumiEditorPage> {onPressed: (_) async {await syncWithProgress();},- title: Text("立即同步状态",- style: TextStyle(fontFamily: fontFamily)),- description: Text('同步状态不一致或仅存在于本地/远端的条目',- style: TextStyle(fontFamily: fontFamily)),+ title: Text("立即同步状态"),+ description: Text('同步状态不一致或仅存在于本地/远端的条目'),),],),@@ -226,7 +217,6 @@ class _BangumiEditorPageState extends State<BangumiEditorPage> {style: TextStyle(fontSize: 12,color: Theme.of(context).colorScheme.primary,- fontFamily: fontFamily,decoration: TextDecoration.underline,),),diff --git a/lib/pages/menu/menu.dart b/lib/pages/menu/menu.dartindex 175d9977..e68e78a5 100644--- a/lib/pages/menu/menu.dart+++ b/lib/pages/menu/menu.dart@@ -3,6 +3,8 @@ import 'package:flutter_modular/flutter_modular.dart';import 'package:flutter/services.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:kazumi/bean/widget/embedded_native_control_area.dart';+import 'package:kazumi/navigation.dart';+import 'package:kazumi/pages/menu/route_visibility.dart';import 'package:kazumi/pages/router.dart';class ScaffoldMenu extends StatefulWidget {@@ -12,10 +14,42 @@ class ScaffoldMenu extends StatefulWidget {State<ScaffoldMenu> createState() => _ScaffoldMenu();}-class _ScaffoldMenu extends State<ScaffoldMenu> {+class _ScaffoldMenu extends State<ScaffoldMenu> with RouteAware {final _outletKey = GlobalKey<RouterOutletState>();DateTime? _lastExitPromptAt;+ /// The shell sits at the bottom of the root stack and stays mounted while+ /// other pages cover it, so it publishes that state for its subtree.+ bool _isCovered = false;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ final route = ModalRoute.of(context);+ if (route is PageRoute<void>) {+ rootRouteObserver.subscribe(this, route);+ }+ }++ @override+ void dispose() {+ rootRouteObserver.unsubscribe(this);+ super.dispose();+ }++ @override+ void didPushNext() => _setCovered(true);++ @override+ void didPopNext() => _setCovered(false);++ void _setCovered(bool value) {+ if (!mounted || _isCovered == value) {+ return;+ }+ setState(() => _isCovered = value);+ }+void _selectDestination(int index) {_lastExitPromptAt = null;final currentIndex =@@ -55,19 +89,22 @@ class _ScaffoldMenu extends State<ScaffoldMenu> {@overrideWidget build(BuildContext context) {final selectedIndex = menu.indexForPath(context.routeState().uri.path);- return PopScope(- canPop: false,- onPopInvokedWithResult: (didPop, _) {- if (!didPop) {- _handleSystemBack(context);- }- },- child: OrientationBuilder(- builder: (context, orientation) {- return orientation == Orientation.portrait- ? _bottomMenu(context, selectedIndex)- : _sideMenu(context, selectedIndex);+ return RouteVisibility(+ isCovered: _isCovered,+ child: PopScope(+ canPop: false,+ onPopInvokedWithResult: (didPop, _) {+ if (!didPop) {+ _handleSystemBack(context);+ }},+ child: OrientationBuilder(+ builder: (context, orientation) {+ return orientation == Orientation.portrait+ ? _bottomMenu(context, selectedIndex)+ : _sideMenu(context, selectedIndex);+ },+ ),),);}diff --git a/lib/pages/menu/route_visibility.dart b/lib/pages/menu/route_visibility.dartnew file mode 100644index 00000000..34654173--- /dev/null+++ b/lib/pages/menu/route_visibility.dart@@ -0,0 +1,27 @@+import 'package:flutter/material.dart';++/// Whether the surrounding route subtree is covered by another page.+///+/// Published by the page that owns the route, so long-lived children can stop+/// background work while hidden instead of inspecting the navigation stack.+class RouteVisibility extends InheritedWidget {+ const RouteVisibility({+ super.key,+ required this.isCovered,+ required super.child,+ });++ final bool isCovered;++ /// Subscribes; dependents are notified only when the state flips.+ static bool isCoveredOf(BuildContext context) {+ return context+ .dependOnInheritedWidgetOfExactType<RouteVisibility>()+ ?.isCovered ??+ false;+ }++ @override+ bool updateShouldNotify(RouteVisibility oldWidget) =>+ isCovered != oldWidget.isCovered;+}diff --git a/lib/pages/my/my_controller.dart b/lib/pages/my/my_controller.dartindex e61ff41d..0e2ce591 100644--- a/lib/pages/my/my_controller.dart+++ b/lib/pages/my/my_controller.dart@@ -1,4 +1,12 @@+import 'dart:async';++import 'package:flutter/foundation.dart' show listEquals;import 'package:kazumi/bean/dialog/dialog_helper.dart';+import 'package:kazumi/modules/my/recent_watch_item.dart';+import 'package:kazumi/modules/my/watch_stats.dart';+import 'package:kazumi/repositories/collect_crud_repository.dart';+import 'package:kazumi/repositories/download_repository.dart';+import 'package:kazumi/repositories/history_repository.dart';import 'package:kazumi/services/logging/logger.dart';import 'package:mobx/mobx.dart';import 'package:kazumi/services/storage/storage.dart';@@ -9,6 +17,86 @@ part 'my_controller.g.dart';class MyController = _MyController with _$MyController;abstract class _MyController with Store {+ _MyController(+ this._historyRepository,+ this._collectCrudRepository,+ this._downloadRepository,+ );++ final IHistoryRepository _historyRepository;+ final ICollectCrudRepository _collectCrudRepository;+ final IDownloadRepository _downloadRepository;++ @observable+ WatchStats watchStats = const WatchStats();++ final ObservableList<RecentWatchItem> recentWatches =+ ObservableList<RecentWatchItem>();++ static const int _recentWatchLimit = 6;+ static const Duration _refreshDebounce = Duration(milliseconds: 300);++ int _viewerCount = 0;+ final List<StreamSubscription<void>> _subscriptions = [];+ Timer? _refreshDebounceTimer;++ /// Follows every source the stats are derived from while a viewer is on+ /// screen, and derives once more to catch up on what changed while there was+ /// none. The count survives a route swap that attaches the next page before+ /// detaching the last.+ void attach() {+ _viewerCount++;+ if (_subscriptions.isEmpty) {+ for (final changes in [+ _historyRepository.changes,+ _collectCrudRepository.changes,+ _downloadRepository.changes,+ ]) {+ _subscriptions.add(changes.listen((_) => _scheduleRefresh()));+ }+ }+ _refresh();+ }++ void detach() {+ if (--_viewerCount > 0) {+ return;+ }+ _refreshDebounceTimer?.cancel();+ _refreshDebounceTimer = null;+ for (final subscription in _subscriptions) {+ subscription.cancel();+ }+ _subscriptions.clear();+ }++ void _scheduleRefresh() {+ // Playback rewrites history every second and a sync restore rewrites+ // collectibles one by one; coalesce those into one pass.+ _refreshDebounceTimer?.cancel();+ _refreshDebounceTimer = Timer(_refreshDebounce, _refresh);+ }++ @action+ void _refresh() {+ final histories = _historyRepository.getAllHistories();+ watchStats = WatchStats.from(+ histories: histories,+ collectibles: _collectCrudRepository.getAllCollectibles(),+ downloadRecords: _downloadRepository.getAllRecords(),+ );+ // getAllHistories is already sorted by most recent watch time.+ final recents = histories+ .take(_recentWatchLimit)+ .map(RecentWatchItem.from)+ .toList(growable: false);+ if (!listEquals(recents, recentWatches)) {+ recentWatches+ ..clear()+ ..addAll(recents);+ }+ }+@observableObservableList<String> shieldList = ObservableList.of([]);diff --git a/lib/pages/my/my_controller.g.dart b/lib/pages/my/my_controller.g.dartindex 114eb127..e60c5e44 100644--- a/lib/pages/my/my_controller.g.dart+++ b/lib/pages/my/my_controller.g.dart@@ -9,6 +9,22 @@ part of 'my_controller.dart';// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiersmixin _$MyController on _MyController, Store {+ late final _$watchStatsAtom =+ Atom(name: '_MyController.watchStats', context: context);++ @override+ WatchStats get watchStats {+ _$watchStatsAtom.reportRead();+ return super.watchStats;+ }++ @override+ set watchStats(WatchStats value) {+ _$watchStatsAtom.reportWrite(value, super.watchStats, () {+ super.watchStats = value;+ });+ }+late final _$shieldListAtom =Atom(name: '_MyController.shieldList', context: context);@@ -25,9 +41,24 @@ mixin _$MyController on _MyController, Store {});}+ late final _$_MyControllerActionController =+ ActionController(name: '_MyController', context: context);++ @override+ void _refresh() {+ final _$actionInfo = _$_MyControllerActionController.startAction(+ name: '_MyController._refresh');+ try {+ return super._refresh();+ } finally {+ _$_MyControllerActionController.endAction(_$actionInfo);+ }+ }+@overrideString toString() {return '''+watchStats: ${watchStats},shieldList: ${shieldList}''';}diff --git a/lib/pages/my/my_module.dart b/lib/pages/my/my_module.dartindex 85938c5b..d32b1de5 100644--- a/lib/pages/my/my_module.dart+++ b/lib/pages/my/my_module.dart@@ -1,4 +1,5 @@import 'package:flutter_modular/flutter_modular.dart';+import 'package:kazumi/pages/my/my_controller.dart';import 'package:kazumi/pages/my/my_page.dart';final myModule = createModule(@@ -7,7 +8,9 @@ final myModule = createModule(c.route('/',transition: TransitionType.none,- child: (context, state) => const MyPage(),+ child: (context, state) => MyPage(+ controller: inject<MyController>(),+ ),);},);diff --git a/lib/pages/my/my_page.dart b/lib/pages/my/my_page.dartindex 1faa9ad9..f8d65a0d 100644--- a/lib/pages/my/my_page.dart+++ b/lib/pages/my/my_page.dart@@ -1,145 +1,519 @@-import 'package:card_settings_ui/card_settings_ui.dart';import 'package:flutter/material.dart';+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/modules/collect/collect_type.dart';+import 'package:kazumi/modules/my/watch_stats.dart';+import 'package:kazumi/pages/menu/route_visibility.dart';+import 'package:kazumi/pages/my/my_controller.dart';+import 'package:kazumi/pages/my/recent_watch_card.dart';+import 'package:kazumi/utils/constants.dart';+import 'package:kazumi/utils/date_time.dart';++class MyPage extends StatefulWidget {+ const MyPage({super.key, required this.controller});++ final MyController controller;++ @override+ State<MyPage> createState() => _MyPageState();+}++class _MyPageState extends State<MyPage> {+ MyController get myController => widget.controller;++ bool _attached = false;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ // This page stays mounted under the player, which rewrites history every+ // second. Drop the subscription while covered, re-derive on the way back.+ _setAttached(!RouteVisibility.isCoveredOf(context));+ }++ @override+ void dispose() {+ _setAttached(false);+ super.dispose();+ }++ void _setAttached(bool value) {+ if (_attached == value) {+ return;+ }+ _attached = value;+ if (value) {+ myController.attach();+ } else {+ myController.detach();+ }+ }++ int _recentCrossCount() {+ final width = MediaQuery.sizeOf(context).width;+ if (width > LayoutBreakpoint.medium['width']!) {+ return 3;+ }+ if (width > LayoutBreakpoint.compact['width']!) {+ return 2;+ }+ return 1;+ }-class MyPage extends StatelessWidget {- const MyPage({super.key});@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;+ final bool wide =+ MediaQuery.sizeOf(context).width > LayoutBreakpoint.compact['width']!;return Scaffold(appBar: const SysAppBar(title: Text('我的'), needTopOffset: false),- body: SettingsList(- maxWidth: 1000,- sections: [- SettingsSection(- title: Text('播放历史与视频源', style: TextStyle(fontFamily: fontFamily)),- tiles: [- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/history/');- },- leading: const Icon(Icons.history_rounded),- title: Text('历史记录', style: TextStyle(fontFamily: fontFamily)),- description:- Text('查看播放历史记录', style: TextStyle(fontFamily: fontFamily)),- ),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/download/');- },- leading: const Icon(Icons.download_rounded),- title: Text('下载管理', style: TextStyle(fontFamily: fontFamily)),- description:- Text('查看和管理离线下载', style: TextStyle(fontFamily: fontFamily)),- ),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/download-settings');- },- leading: const Icon(Icons.settings_rounded),- title: Text('下载设置', style: TextStyle(fontFamily: fontFamily)),- description: Text('配置下载并发数等参数',- style: TextStyle(fontFamily: fontFamily)),- ),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/plugin/');- },- leading: const Icon(Icons.extension),- title: Text('规则管理', style: TextStyle(fontFamily: fontFamily)),- description:- Text('管理番剧资源规则', style: TextStyle(fontFamily: fontFamily)),+ body: SafeArea(+ top: false,+ bottom: false,+ child: Observer(+ builder: (context) {+ final stats = myController.watchStats;+ return SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),+ child: Center(+ child: ConstrainedBox(+ constraints: BoxConstraints(maxWidth: wide ? 1400 : 1100),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (wide) _wideHeader(stats) else ..._narrowHeader(stats),+ ..._recentSection(),+ ],+ ),+ ),),+ );+ },+ ),+ ),+ );+ }++ List<Widget> _narrowHeader(WatchStats stats) {+ return [+ _CollectHero(stats: stats),+ const SizedBox(height: 12),+ _statTiles(stats),+ const SizedBox(height: 12),+ _entryGroup(stats),+ ];+ }++ Widget _wideHeader(WatchStats stats) {+ return Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Expanded(+ flex: 3,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ _CollectHero(stats: stats),+ const SizedBox(height: 12),+ _statTiles(stats),],),- SettingsSection(- title: Text('播放器设置', style: TextStyle(fontFamily: fontFamily)),- tiles: [- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/player');- },- leading: const Icon(Icons.display_settings_rounded),- title: Text('播放设置', style: TextStyle(fontFamily: fontFamily)),- description:- Text('设置播放器相关参数', style: TextStyle(fontFamily: fontFamily)),- ),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/danmaku/');- },- leading: const Icon(Icons.subtitles_rounded),- title: Text('弹幕设置', style: TextStyle(fontFamily: fontFamily)),- description:- Text('设置弹幕相关参数', style: TextStyle(fontFamily: fontFamily)),- ),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/keyboard');- },- leading: const Icon(Icons.keyboard_rounded),- title: Text('操作设置', style: TextStyle(fontFamily: fontFamily)),- description:- Text('设置播放器按键映射', style: TextStyle(fontFamily: fontFamily)),+ ),+ const SizedBox(width: 16),+ Expanded(flex: 2, child: _entryGroup(stats)),+ ],+ );+ }++ List<Widget> _recentSection() {+ final crossCount = _recentCrossCount();+ final int maxCount = crossCount == 1 ? 3 : crossCount * 2;+ final int count = myController.recentWatches.length < maxCount+ ? myController.recentWatches.length+ : maxCount;+ if (count == 0) {+ return const [];+ }+ return [+ const SizedBox(height: 24),+ _sectionLabel('继续观看'),+ const SizedBox(height: 12),+ GridView.builder(+ shrinkWrap: true,+ padding: EdgeInsets.zero,+ physics: const NeverScrollableScrollPhysics(),+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(+ crossAxisCount: crossCount,+ crossAxisSpacing: StyleString.cardSpace,+ mainAxisSpacing: StyleString.cardSpace,+ mainAxisExtent: 128,+ ),+ itemCount: count,+ itemBuilder: (context, index) {+ final item = myController.recentWatches[index];+ return RecentWatchCard(key: ValueKey(item.id), item: item);+ },+ ),+ ];+ }++ Widget _sectionLabel(String text) {+ final theme = Theme.of(context);+ return Padding(+ padding: const EdgeInsets.only(left: 4),+ child: Text(+ text,+ style: theme.textTheme.titleSmall?.copyWith(+ color: theme.colorScheme.onSurfaceVariant,+ ),+ ),+ );+ }++ Widget _statTiles(WatchStats stats) {+ final tiles = <Widget>[+ _StatTile(+ value: '${stats.watchedBangumiCount}',+ unit: '部',+ label: '看过番剧',+ ),+ _StatTile(+ value: '${stats.watchedEpisodeCount}',+ unit: '集',+ label: '观看集数',+ ),+ _StatTile(+ value: '${stats.downloadTaskCount}',+ unit: '集',+ label: '离线缓存',+ ),+ ];+ // Tiles hold different amounts of text; stretch keeps them level.+ return IntrinsicHeight(+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ for (var i = 0; i < tiles.length; i++) ...[+ if (i > 0) const SizedBox(width: 12),+ Expanded(child: tiles[i]),+ ],+ ],+ ),+ );+ }++ /// Peer entries share one surface: the tonal accent belongs on the icon+ /// badge, not on the card, so the page keeps a single point of emphasis.+ /// Grouped corners (round outside, tight inside) tie them into one block.+ Widget _entryGroup(WatchStats stats) {+ final entries = <_EntryData>[+ _EntryData(+ icon: Icons.history_rounded,+ title: '历史记录',+ subtitle: stats.lastWatchName != null+ ? '最近看到 ${stats.lastWatchName}'+ : '还没有观看记录',+ onTap: () => context.pushNamed('/settings/history/'),+ ),+ _EntryData(+ icon: Icons.download_rounded,+ title: '离线下载',+ subtitle: '缓存任务与本地文件',+ onTap: () => context.pushNamed('/settings/download/'),+ ),+ _EntryData(+ icon: Icons.settings_rounded,+ title: '设置',+ subtitle: '播放、弹幕、外观与规则',+ onTap: () => context.pushNamed('/settings/'),+ ),+ ];+ const outer = Radius.circular(16);+ const inner = Radius.circular(4);+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ for (var i = 0; i < entries.length; i++) ...[+ if (i > 0) const SizedBox(height: 2),+ _EntryTile(+ data: entries[i],+ borderRadius: BorderRadius.vertical(+ top: i == 0 ? outer : inner,+ bottom: i == entries.length - 1 ? outer : inner,+ ),+ ),+ ],+ ],+ );+ }+}++class _CollectHero extends StatelessWidget {+ const _CollectHero({required this.stats});++ final WatchStats stats;++ static const List<CollectType> _order = [+ CollectType.watching,+ CollectType.planToWatch,+ CollectType.onHold,+ CollectType.watched,+ CollectType.abandoned,+ ];++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ final lastWatchTime = stats.lastWatchTime;+ final String caption = lastWatchTime == null+ ? '收藏番剧后会在这里汇总'+ : '最近观看 ${formatTimestampToRelativeTime(lastWatchTime.millisecondsSinceEpoch ~/ 1000)}';++ return Container(+ padding: const EdgeInsets.all(20),+ decoration: BoxDecoration(+ color: colorScheme.surfaceContainerLow,+ borderRadius: BorderRadius.circular(16),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Row(+ children: [+ Container(+ width: 36,+ height: 36,+ decoration: BoxDecoration(+ color: colorScheme.primaryContainer,+ shape: BoxShape.circle,+ ),+ child: Icon(+ Icons.favorite_rounded,+ size: 18,+ color: colorScheme.onPrimaryContainer,+ ),),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/proxy');- },- leading: const Icon(Icons.vpn_key_rounded),- title: Text('代理设置', style: TextStyle(fontFamily: fontFamily)),- description:- Text('配置HTTP代理', style: TextStyle(fontFamily: fontFamily)),+ const SizedBox(width: 12),+ Text(+ '我的追番',+ style: textTheme.titleMedium?.copyWith(+ color: colorScheme.onSurface,+ ),),],),- SettingsSection(- title: Text('应用与外观', style: TextStyle(fontFamily: fontFamily)),- tiles: [- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/theme');- },- leading: const Icon(Icons.palette_rounded),- title: Text('外观设置', style: TextStyle(fontFamily: fontFamily)),- description: Text('设置应用主题和刷新率',- style: TextStyle(fontFamily: fontFamily)),- ),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/interface');- },- leading: const Icon(Icons.pages_rounded),- title: Text('界面设置', style: TextStyle(fontFamily: fontFamily)),- description:- Text('设置应用界面样式', style: TextStyle(fontFamily: fontFamily)),+ const SizedBox(height: 16),+ Text.rich(+ TextSpan(+ children: [+ TextSpan(+ text: '${stats.collectedCount}',+ style: textTheme.displaySmall?.copyWith(+ color: colorScheme.primary,+ fontWeight: FontWeight.w500,+ ),+ ),+ TextSpan(+ text: ' 部',+ style: textTheme.titleMedium?.copyWith(+ color: colorScheme.onSurfaceVariant,+ ),+ ),+ ],+ ),+ ),+ const SizedBox(height: 12),+ if (stats.collectedCount > 0)+ Wrap(+ spacing: 8,+ runSpacing: 8,+ children: [+ for (final type in _order)+ if ((stats.collectCounts[type] ?? 0) > 0)+ _CollectChip(+ label: type.label,+ count: stats.collectCounts[type]!,+ ),+ ],+ ),+ if (stats.collectedCount > 0) const SizedBox(height: 12),+ Text(+ caption,+ style: textTheme.bodyMedium?.copyWith(+ color: colorScheme.onSurfaceVariant,+ ),+ ),+ ],+ ),+ );+ }+}++class _CollectChip extends StatelessWidget {+ const _CollectChip({required this.label, required this.count});++ final String label;+ final int count;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ return Container(+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),+ decoration: BoxDecoration(+ color: colorScheme.secondaryContainer,+ borderRadius: BorderRadius.circular(8),+ ),+ child: Text(+ '$label $count',+ style: textTheme.labelMedium?.copyWith(+ color: colorScheme.onSecondaryContainer,+ ),+ ),+ );+ }+}++class _StatTile extends StatelessWidget {+ const _StatTile({+ required this.value,+ required this.unit,+ required this.label,+ });++ final String value;+ final String unit;+ final String label;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ return Container(+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 16),+ decoration: BoxDecoration(+ color: colorScheme.surfaceContainerLow,+ borderRadius: BorderRadius.circular(16),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text.rich(+ TextSpan(+ children: [+ TextSpan(+ text: value,+ style: textTheme.headlineSmall?.copyWith(+ color: colorScheme.onSurface,+ fontWeight: FontWeight.w500,+ ),+ ),+ TextSpan(+ text: ' $unit',+ style: textTheme.bodyMedium?.copyWith(+ color: colorScheme.onSurfaceVariant,+ ),+ ),+ ],+ ),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ const SizedBox(height: 2),+ Text(+ label,+ style: textTheme.bodyMedium?.copyWith(+ color: colorScheme.onSurfaceVariant,+ ),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),+ );+ }+}++class _EntryData {+ const _EntryData({+ required this.icon,+ required this.title,+ required this.subtitle,+ required this.onTap,+ });++ final IconData icon;+ final String title;+ final String subtitle;+ final VoidCallback onTap;+}++class _EntryTile extends StatelessWidget {+ const _EntryTile({required this.data, required this.borderRadius});++ final _EntryData data;+ final BorderRadiusGeometry borderRadius;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ return Material(+ color: colorScheme.surfaceContainerLow,+ borderRadius: borderRadius,+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ onTap: data.onTap,+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),+ child: Row(+ children: [+ Container(+ width: 36,+ height: 36,+ decoration: BoxDecoration(+ color: colorScheme.secondaryContainer,+ shape: BoxShape.circle,+ ),+ child: Icon(+ data.icon,+ size: 18,+ color: colorScheme.onSecondaryContainer,+ ),),- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/webdav/');- },- leading: const Icon(Icons.cloud),- title: Text('同步设置', style: TextStyle(fontFamily: fontFamily)),- description:- Text('设置同步参数', style: TextStyle(fontFamily: fontFamily)),+ const SizedBox(width: 14),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ data.title,+ style: textTheme.titleMedium?.copyWith(+ color: colorScheme.onSurface,+ ),+ ),+ const SizedBox(height: 2),+ Text(+ data.subtitle,+ style: textTheme.bodySmall?.copyWith(+ color: colorScheme.onSurfaceVariant,+ ),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),),- ],- ),- SettingsSection(- title: Text('其他', style: TextStyle(fontFamily: fontFamily)),- tiles: [- SettingsTile.navigation(- onPressed: (_) {- context.pushNamed('/settings/about/');- },- leading: const Icon(Icons.info_outline_rounded),- title: Text('关于', style: TextStyle(fontFamily: fontFamily)),+ Icon(+ Icons.chevron_right_rounded,+ size: 20,+ color: colorScheme.onSurfaceVariant,),],),- ],+ ),),);}diff --git a/lib/pages/my/recent_watch_card.dart b/lib/pages/my/recent_watch_card.dartnew file mode 100644index 00000000..81c860a3--- /dev/null+++ b/lib/pages/my/recent_watch_card.dart@@ -0,0 +1,196 @@+import 'package:flutter/material.dart';+import 'package:flutter_modular/flutter_modular.dart';+import 'package:kazumi/bean/card/network_img_layer.dart';+import 'package:kazumi/bean/dialog/dialog_helper.dart';+import 'package:kazumi/modules/my/recent_watch_item.dart';+import 'package:kazumi/services/player/history_playback_service.dart';+import 'package:kazumi/services/plugin/rule_engine_models.dart'+ show RuleCancelToken;+import 'package:kazumi/utils/date_time.dart';+import 'package:kazumi/utils/device.dart';++/// Continue-watching card: opens playback, nothing else.+class RecentWatchCard extends StatefulWidget {+ const RecentWatchCard({super.key, required this.item});++ final RecentWatchItem item;++ @override+ State<RecentWatchCard> createState() => _RecentWatchCardState();+}++class _RecentWatchCardState extends State<RecentWatchCard> {+ static const double _coverWidth = 78;+ static const double _coverHeight = 104;++ final HistoryPlaybackService _playbackService =+ inject<HistoryPlaybackService>();++ RuleCancelToken? _cancelToken;++ @override+ void dispose() {+ _cancelToken?.cancel();+ super.dispose();+ }++ Future<void> _play() async {+ _cancelToken?.cancel();+ final cancelToken = RuleCancelToken();+ _cancelToken = cancelToken;+ KazumiDialog.showLoading(+ msg: '获取中',+ barrierDismissible: isDesktop(),+ onDismiss: cancelToken.cancel,+ );+ final result = await _playbackService.open(+ widget.item.history,+ cancelToken: cancelToken,+ );+ KazumiDialog.dismiss();+ if (!mounted) return;+ switch (result) {+ case HistoryPlaybackReady(:final args):+ context.pushNamed('/video/', arguments: args);+ case HistoryPlaybackUnavailable(:final reason):+ KazumiDialog.showToast(message: reason);+ }+ }++ @override+ Widget build(BuildContext context) {+ final theme = Theme.of(context);+ final colorScheme = theme.colorScheme;+ final item = widget.item;++ return Material(+ color: colorScheme.surfaceContainerLow,+ borderRadius: BorderRadius.circular(16),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ onTap: _play,+ child: Padding(+ padding: const EdgeInsets.all(12),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _cover(colorScheme),+ const SizedBox(width: 14),+ Expanded(+ child: SizedBox(+ height: _coverHeight,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ // Titles run one or two lines; splitting the slack keeps+ // both cases balanced against the cover height.+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Text(+ item.title,+ style: theme.textTheme.titleSmall?.copyWith(+ color: colorScheme.onSurface,+ fontWeight: FontWeight.w600,+ height: 1.25,+ ),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ ),+ Text(+ '看到 ${item.episodeLabel}',+ style: theme.textTheme.bodyMedium?.copyWith(+ color: colorScheme.onSurfaceVariant,+ ),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ Row(+ children: [+ _pill(+ label: item.sourceLabel,+ background: colorScheme.secondaryContainer,+ foreground: colorScheme.onSecondaryContainer,+ ),+ const SizedBox(width: 6),+ Flexible(+ child: _pill(+ label: item.adapterName,+ background: colorScheme.surfaceContainerHighest,+ foreground: colorScheme.onSurfaceVariant,+ ),+ ),+ const SizedBox(width: 8),+ Text(+ formatTimestampToRelativeTime(+ item.lastWatchTime.millisecondsSinceEpoch ~/ 1000,+ ),+ style: theme.textTheme.labelSmall?.copyWith(+ color: colorScheme.outline,+ ),+ maxLines: 1,+ ),+ ],+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }++ Widget _cover(ColorScheme colorScheme) {+ return SizedBox(+ width: _coverWidth,+ height: _coverHeight,+ child: Stack(+ alignment: Alignment.center,+ children: [+ NetworkImgLayer(+ src: widget.item.coverUrl,+ width: _coverWidth,+ height: _coverHeight,+ ),+ Container(+ width: 34,+ height: 34,+ decoration: BoxDecoration(+ color: colorScheme.primary.withValues(alpha: 0.92),+ shape: BoxShape.circle,+ ),+ child: Icon(+ Icons.play_arrow_rounded,+ size: 22,+ color: colorScheme.onPrimary,+ ),+ ),+ ],+ ),+ );+ }++ Widget _pill({+ required String label,+ required Color background,+ required Color foreground,+ }) {+ return Container(+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),+ decoration: BoxDecoration(+ color: background,+ borderRadius: BorderRadius.circular(8),+ ),+ child: Text(+ label,+ style: Theme.of(context)+ .textTheme+ .labelSmall+ ?.copyWith(color: foreground),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ );+ }+}diff --git a/lib/pages/plugin_editor/plugin_view_page.dart b/lib/pages/plugin_editor/plugin_view_page.dartindex 0ac96a88..20d76999 100644--- a/lib/pages/plugin_editor/plugin_view_page.dart+++ b/lib/pages/plugin_editor/plugin_view_page.dart@@ -8,7 +8,7 @@ import 'package:kazumi/bean/card/rule_card.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:kazumi/plugins/plugins.dart';import 'package:kazumi/plugins/plugins_controller.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/pages/plugin_editor/plugin_update_actions.dart';import 'package:kazumi/services/logging/logger.dart';import 'package:kazumi/utils/encoding.dart';@@ -190,86 +190,83 @@ class _PluginViewPageState extends State<PluginViewPage> {}onBackPressed(context);},- child: Scaffold(- appBar: SysAppBar(- title: isMultiSelectMode- ? Text('已选择 ${selectedNames.length} 项')- : const Text('规则管理'),- leading: isMultiSelectMode- ? IconButton(- icon: const Icon(Icons.close),- onPressed: () {- setState(() {- isMultiSelectMode = false;- selectedNames.clear();- });- },- )- : null,- actions: [- if (isMultiSelectMode) ...[- IconButton(- onPressed: selectedNames.isEmpty- ? null- : () {- KazumiDialog.show(- builder: (context) => AlertDialog(- title: const Text('删除规则'),- content:- Text('确定要删除选中的 ${selectedNames.length} 条规则吗?'),- actions: [- TextButton(- onPressed: () => KazumiDialog.dismiss(),- child: Text(- '取消',- style: TextStyle(- color: Theme.of(context)- .colorScheme- .outline),- ),- ),- TextButton(- onPressed: () async {- try {- await pluginsController- .removePlugins(selectedNames);- } catch (_) {- KazumiDialog.showToast(message: '删除规则失败');- return;- }- if (!mounted) return;- setState(() {- isMultiSelectMode = false;- selectedNames.clear();- });- KazumiDialog.dismiss();- },- child: const Text('删除'),- ),- ],- ),- );- },- icon: const Icon(Icons.delete),- ),- ] else ...[- IconButton(+ child: SettingsDetailScaffold(+ title: isMultiSelectMode+ ? Text('已选择 ${selectedNames.length} 项')+ : const Text('规则管理'),+ leading: isMultiSelectMode+ ? IconButton(+ icon: const Icon(Icons.close),onPressed: () {- _handleUpdate();+ setState(() {+ isMultiSelectMode = false;+ selectedNames.clear();+ });},- tooltip: '更新全部',- icon: const Icon(Icons.update),- ),- IconButton(- onPressed: () {- _handleAdd();- },- tooltip: '添加规则',- icon: const Icon(Icons.add),)- ],+ : null,+ actions: [+ if (isMultiSelectMode) ...[+ IconButton(+ onPressed: selectedNames.isEmpty+ ? null+ : () {+ KazumiDialog.show(+ builder: (context) => AlertDialog(+ title: const Text('删除规则'),+ content:+ Text('确定要删除选中的 ${selectedNames.length} 条规则吗?'),+ actions: [+ TextButton(+ onPressed: () => KazumiDialog.dismiss(),+ child: Text(+ '取消',+ style: TextStyle(+ color:+ Theme.of(context).colorScheme.outline),+ ),+ ),+ TextButton(+ onPressed: () async {+ try {+ await pluginsController+ .removePlugins(selectedNames);+ } catch (_) {+ KazumiDialog.showToast(message: '删除规则失败');+ return;+ }+ if (!mounted) return;+ setState(() {+ isMultiSelectMode = false;+ selectedNames.clear();+ });+ KazumiDialog.dismiss();+ },+ child: const Text('删除'),+ ),+ ],+ ),+ );+ },+ icon: const Icon(Icons.delete),+ ),+ ] else ...[+ IconButton(+ onPressed: () {+ _handleUpdate();+ },+ tooltip: '更新全部',+ icon: const Icon(Icons.update),+ ),+ IconButton(+ onPressed: () {+ _handleAdd();+ },+ tooltip: '添加规则',+ icon: const Icon(Icons.add),+ )],- ),+ ],body: Observer(builder: (context) {return pluginsController.pluginList.isEmpty? const Center(diff --git a/lib/pages/settings/danmaku/danmaku_settings.dart b/lib/pages/settings/danmaku/danmaku_settings.dartindex 236aaca6..2018819e 100644--- a/lib/pages/settings/danmaku/danmaku_settings.dart+++ b/lib/pages/settings/danmaku/danmaku_settings.dart@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';import 'package:flutter_modular/flutter_modular.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:kazumi/utils/device.dart';class DanmakuSettingsPage extends StatefulWidget {@@ -157,19 +157,18 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: true,onPopInvokedWithResult: (bool didPop, Object? result) {onBackPressed(context);},- child: Scaffold(- appBar: const SysAppBar(title: Text('弹幕设置')),+ child: SettingsDetailScaffold(+ title: const Text('弹幕设置'),body: SettingsList(maxWidth: 1000,sections: [SettingsSection(- title: Text('弹幕来源', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕来源'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -179,8 +178,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {danmakuBiliBiliSource);setState(() {});},- title: Text('BiliBili',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('BiliBili'),initialValue: danmakuBiliBiliSource,),SettingsTile.switchTile(@@ -190,8 +188,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuGamerSource, danmakuGamerSource);setState(() {});},- title:- Text('Gamer', style: TextStyle(fontFamily: fontFamily)),+ title: Text('Gamer'),initialValue: danmakuGamerSource,),SettingsTile.switchTile(@@ -201,29 +198,27 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuDanDanSource, danmakuDanDanSource);setState(() {});},- title:- Text('弹弹play', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹弹play'),initialValue: danmakuDanDanSource,),],),SettingsSection(- title: Text('弹幕屏蔽', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕屏蔽'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {context.pushNamed('/settings/danmaku/shield');},- title:- Text('关键词屏蔽', style: TextStyle(fontFamily: fontFamily)),+ title: Text('关键词屏蔽'),),],),SettingsSection(- title: Text('弹幕显示', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕显示'),tiles: [SettingsTile(- title: Text('弹幕区域', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕区域'),description: Slider(value: defaultDanmakuArea,min: 0,@@ -236,8 +231,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {),),SettingsTile(- title:- Text('弹幕持续时间', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕持续时间'),description: Slider(value: defaultDanmakuDuration,min: 2,@@ -250,7 +244,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {),),SettingsTile(- title: Text('弹幕行高', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕行高'),description: Slider(value: defaultDanmakuLineHeight,min: 0,@@ -270,10 +264,8 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuFollowSpeed, danmakuFollowSpeed);setState(() {});},- title: Text('弹幕跟随视频倍速',- style: TextStyle(fontFamily: fontFamily)),- description: Text('开启后弹幕速度会随视频倍速而改变',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕跟随视频倍速'),+ description: Text('开启后弹幕速度会随视频倍速而改变'),initialValue: danmakuFollowSpeed,),SettingsTile.switchTile(@@ -283,7 +275,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuTop, danmakuTop);setState(() {});},- title: Text('顶部弹幕', style: TextStyle(fontFamily: fontFamily)),+ title: Text('顶部弹幕'),initialValue: danmakuTop,),SettingsTile.switchTile(@@ -293,7 +285,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuBottom, danmakuBottom);setState(() {});},- title: Text('底部弹幕', style: TextStyle(fontFamily: fontFamily)),+ title: Text('底部弹幕'),initialValue: danmakuBottom,),SettingsTile.switchTile(@@ -303,7 +295,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuScroll, danmakuScroll);setState(() {});},- title: Text('滚动弹幕', style: TextStyle(fontFamily: fontFamily)),+ title: Text('滚动弹幕'),initialValue: danmakuScroll,),SettingsTile.switchTile(@@ -313,9 +305,8 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuMassive, danmakuMassive);setState(() {});},- title: Text('海量弹幕', style: TextStyle(fontFamily: fontFamily)),- description: Text('弹幕过多时进行叠加绘制',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('海量弹幕'),+ description: Text('弹幕过多时进行叠加绘制'),initialValue: danmakuMassive,),SettingsTile.switchTile(@@ -326,15 +317,14 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {danmakuDeduplication);setState(() {});},- title: Text('弹幕去重', style: TextStyle(fontFamily: fontFamily)),- description: Text('相同内容弹幕过多时合并为一条弹幕',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕去重'),+ description: Text('相同内容弹幕过多时合并为一条弹幕'),initialValue: danmakuDeduplication,),],),SettingsSection(- title: Text('弹幕样式', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕样式'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -343,12 +333,11 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuBorder, danmakuBorder);setState(() {});},- title: Text('弹幕描边', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕描边'),initialValue: danmakuBorder,),SettingsTile(- title:- Text('弹幕描边粗细', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕描边粗细'),description: Slider(value: defaultdanmakuBorderSize,min: 0.1,@@ -368,11 +357,11 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {SettingsKeys.danmakuColor, danmakuColor);setState(() {});},- title: Text('弹幕颜色', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕颜色'),initialValue: danmakuColor,),SettingsTile(- title: Text('字体大小', style: TextStyle(fontFamily: fontFamily)),+ title: Text('字体大小'),description: Slider(value: defaultDanmakuFontSize,min: 10,@@ -384,7 +373,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {),),SettingsTile(- title: Text('字体字重', style: TextStyle(fontFamily: fontFamily)),+ title: Text('字体字重'),description: Slider(value: defaultDanmakuFontWeight.toDouble(),min: 1,@@ -397,8 +386,7 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {),),SettingsTile(- title:- Text('弹幕不透明度', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕不透明度'),description: Slider(value: defaultDanmakuOpacity,min: 0.1,@@ -414,12 +402,10 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {),SettingsSection(tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) => resetDanmakuSettings(),- title:- Text('恢复默认设置', style: TextStyle(fontFamily: fontFamily)),- description: Text('将弹幕相关设置恢复为默认值',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('恢复默认设置'),+ description: Text('将弹幕相关设置恢复为默认值'),),],),diff --git a/lib/pages/settings/danmaku/danmaku_settings_sheet.dart b/lib/pages/settings/danmaku/danmaku_settings_sheet.dartindex 235b5897..2b5ba3ca 100644--- a/lib/pages/settings/danmaku/danmaku_settings_sheet.dart+++ b/lib/pages/settings/danmaku/danmaku_settings_sheet.dart@@ -5,7 +5,7 @@ import 'package:kazumi/bean/dialog/material_bottom_sheet.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/pages/settings/danmaku/danmaku_shield_settings_sheet.dart';import 'package:kazumi/pages/settings/danmaku/danmaku_time_offset_sheet.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:kazumi/utils/device.dart';enum _DanmakuSettingsDestination {@@ -67,7 +67,6 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return SafeArea(bottom: false,child: Scaffold(@@ -82,25 +81,21 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {child: SettingsList(sections: [SettingsSection(- title:- Text('弹幕屏蔽', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕屏蔽'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {_showDanmakuShieldSheet();},- title: Text('关键词屏蔽',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('关键词屏蔽'),),],),SettingsSection(- title:- Text('弹幕样式', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕样式'),tiles: [SettingsTile(- title: Text('字体大小',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('字体大小'),description: Slider(value: widget.danmakuController.option.fontSize,min: 10,@@ -121,8 +116,7 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {),),SettingsTile(- title: Text('弹幕不透明度',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕不透明度'),description: Slider(value: widget.danmakuController.option.opacity,min: 0.1,@@ -145,16 +139,14 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {],),SettingsSection(- title:- Text('弹幕显示', style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕显示'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (context) {Navigator.of(context).pop(_DanmakuSettingsDestination.timeOffset);},- title: Text('时间轴偏移',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('时间轴偏移'),value: Text(formatDanmakuTimeOffset(normalizeDanmakuTimeOffset(@@ -162,12 +154,10 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {SettingsKeys.danmakuTimeOffset),),),- style: TextStyle(fontFamily: fontFamily),),),SettingsTile(- title: Text('弹幕区域',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('弹幕区域'),description: Slider(value: widget.danmakuController.option.area,min: 0,@@ -188,8 +178,7 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {),),SettingsTile(- title: Text('持续时间',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('持续时间'),description: Slider(value: widget.danmakuController.option.duration.toDouble(),@@ -212,8 +201,7 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {),),SettingsTile(- title: Text('行高',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('行高'),description: Slider(value: widget.danmakuController.option.lineHeight,min: 0,@@ -247,8 +235,7 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {GStorage.putSetting<bool>(SettingsKeys.danmakuTop, show);},- title: Text('顶部弹幕',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('顶部弹幕'),initialValue: !widget.danmakuController.option.hideTop,),SettingsTile.switchTile(@@ -263,8 +250,7 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {GStorage.putSetting<bool>(SettingsKeys.danmakuBottom, show);},- title: Text('底部弹幕',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('底部弹幕'),initialValue:!widget.danmakuController.option.hideBottom,),@@ -280,8 +266,7 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {GStorage.putSetting<bool>(SettingsKeys.danmakuScroll, show);},- title: Text('滚动弹幕',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('滚动弹幕'),initialValue:!widget.danmakuController.option.hideScroll,),@@ -295,10 +280,8 @@ class _DanmakuSettingsSheetState extends State<_DanmakuSettingsSheet> {widget.onUpdateDanmakuSpeed?.call();setState(() {});},- title: Text('跟随视频倍速',- style: TextStyle(fontFamily: fontFamily)),- description: Text('弹幕速度随视频倍速变化',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('跟随视频倍速'),+ description: Text('弹幕速度随视频倍速变化'),initialValue: GStorage.getSetting<bool>(SettingsKeys.danmakuFollowSpeed),),diff --git a/lib/pages/settings/danmaku/danmaku_time_offset_sheet.dart b/lib/pages/settings/danmaku/danmaku_time_offset_sheet.dartindex ef823e13..42dc0173 100644--- a/lib/pages/settings/danmaku/danmaku_time_offset_sheet.dart+++ b/lib/pages/settings/danmaku/danmaku_time_offset_sheet.dart@@ -75,7 +75,6 @@ class _DanmakuTimeOffsetSheetState extends State<DanmakuTimeOffsetSheet> {Widget build(BuildContext context) {final theme = Theme.of(context);final colorScheme = theme.colorScheme;- final fontFamily = theme.textTheme.bodyMedium?.fontFamily;final direction = _offset == 0 ? '无偏移' : (_offset > 0 ? '延后' : '提前');return SafeArea(@@ -109,7 +108,6 @@ class _DanmakuTimeOffsetSheetState extends State<DanmakuTimeOffsetSheet> {direction,style: theme.textTheme.titleMedium?.copyWith(color: colorScheme.onSecondaryContainer,- fontFamily: fontFamily,fontWeight: FontWeight.w600,),),@@ -118,7 +116,6 @@ class _DanmakuTimeOffsetSheetState extends State<DanmakuTimeOffsetSheet> {_formatDanmakuOffsetDuration(_offset),style: theme.textTheme.displaySmall?.copyWith(color: colorScheme.onSecondaryContainer,- fontFamily: fontFamily,fontFeatures: const [FontFeature.tabularFigures()],@@ -135,7 +132,6 @@ class _DanmakuTimeOffsetSheetState extends State<DanmakuTimeOffsetSheet> {'提前 3:00',style: theme.textTheme.labelMedium?.copyWith(color: colorScheme.onSurfaceVariant,- fontFamily: fontFamily,),),const Spacer(),@@ -143,7 +139,6 @@ class _DanmakuTimeOffsetSheetState extends State<DanmakuTimeOffsetSheet> {'延后 3:00',style: theme.textTheme.labelMedium?.copyWith(color: colorScheme.onSurfaceVariant,- fontFamily: fontFamily,),),],diff --git a/lib/pages/settings/decoder_settings.dart b/lib/pages/settings/decoder_settings.dartindex 45d812ec..f52ae2df 100644--- a/lib/pages/settings/decoder_settings.dart+++ b/lib/pages/settings/decoder_settings.dart@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/utils/constants.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';class DecoderSettings extends StatefulWidget {const DecoderSettings({super.key});@@ -24,7 +24,6 @@ class _DecoderSettingsState extends State<DecoderSettings> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return Scaffold(appBar: const SysAppBar(title: Text('硬件解码器'),@@ -32,26 +31,23 @@ class _DecoderSettingsState extends State<DecoderSettings> {body: SettingsList(maxWidth: 1000,sections: [- SettingsSection(- title: Text('选择不受支持的解码器将回退到软件解码',- style: TextStyle(fontFamily: fontFamily)),+ SettingsRadioSection<String>(+ title: Text('选择不受支持的解码器将回退到软件解码'),+ groupValue: decoder.value,+ onChanged: (String? value) {+ if (value != null) {+ GStorage.putSetting<String>(+ SettingsKeys.hardwareDecoder, value);+ setState(() {+ decoder.value = value;+ });+ }+ },tiles: hardwareDecodersList.entries.map((e) => SettingsTile<String>.radioTile(- title:- Text(e.key, style: TextStyle(fontFamily: fontFamily)),- description: Text(e.value,- style: TextStyle(fontFamily: fontFamily)),+ title: Text(e.key),+ description: Text(e.value),radioValue: e.key,- groupValue: decoder.value,- onChanged: (String? value) {- if (value != null) {- GStorage.putSetting<String>(- SettingsKeys.hardwareDecoder, value);- setState(() {- decoder.value = value;- });- }- },)).toList(),),diff --git a/lib/pages/settings/displaymode_settings.dart b/lib/pages/settings/displaymode_settings.dartindex 84d87b7c..04c0732b 100644--- a/lib/pages/settings/displaymode_settings.dart+++ b/lib/pages/settings/displaymode_settings.dart@@ -3,7 +3,7 @@ import 'package:flutter/scheduler.dart';import 'package:flutter/services.dart';import 'package:flutter_displaymode/flutter_displaymode.dart';import 'package:kazumi/services/storage/storage.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';class SetDisplayMode extends StatefulWidget {const SetDisplayMode({super.key});@@ -67,7 +67,6 @@ class _SetDisplayModeState extends State<SetDisplayMode> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return Scaffold(appBar: AppBar(title: const Text('屏幕帧率设置')),body: (modes.isEmpty)@@ -75,26 +74,22 @@ class _SetDisplayModeState extends State<SetDisplayMode> {: SettingsList(maxWidth: 1000,sections: [- SettingsSection(- title: Text('没有生效? 重启app试试',- style: TextStyle(fontFamily: fontFamily)),+ SettingsRadioSection<DisplayMode>(+ title: Text('没有生效? 重启app试试'),+ groupValue: preferred,+ onChanged: (DisplayMode? newMode) async {+ await FlutterDisplayMode.setPreferredMode(newMode!);+ await Future<dynamic>.delayed(+ const Duration(milliseconds: 100),+ );+ await fetchAll();+ },tiles: modes.map((e) => SettingsTile<DisplayMode>.radioTile(radioValue: e,- groupValue: preferred,- onChanged: (DisplayMode? newMode) async {- await FlutterDisplayMode.setPreferredMode(- newMode!);- await Future<dynamic>.delayed(- const Duration(milliseconds: 100),- );- await fetchAll();- },title: e == DisplayMode.auto- ? Text('自动',- style: TextStyle(fontFamily: fontFamily))- : Text('$e${e == active ? " [系统]" : ""}',- style: TextStyle(fontFamily: fontFamily)),+ ? Text('自动')+ : Text('$e${e == active ? " [系统]" : ""}'),)).toList(),),diff --git a/lib/pages/settings/download_settings.dart b/lib/pages/settings/download_settings.dartindex 8ebbcb6c..a2722ee2 100644--- a/lib/pages/settings/download_settings.dart+++ b/lib/pages/settings/download_settings.dart@@ -1,12 +1,12 @@import 'dart:io';import 'package:flutter/material.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:kazumi/services/platform/secure_bookmark_service.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/utils/file_system.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:file_picker/file_picker.dart';class DownloadSettingsPage extends StatefulWidget {@@ -108,23 +108,21 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;- return Scaffold(- appBar: const SysAppBar(title: Text('下载设置')),+ return SettingsDetailScaffold(+ title: const Text('下载设置'),body: SettingsList(maxWidth: 1000,sections: [SettingsSection(- title: Text('并发设置', style: TextStyle(fontFamily: fontFamily)),+ title: Text('并发设置'),tiles: [SettingsTile(- title: Text('同时下载集数', style: TextStyle(fontFamily: fontFamily)),+ title: Text('同时下载集数'),description: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [Text('同时下载 $parallelEpisodes 集',- style: TextStyle(fontFamily: fontFamily),),Slider(value: parallelEpisodes.toDouble(),@@ -144,13 +142,12 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {),),SettingsTile(- title: Text('分片并发数', style: TextStyle(fontFamily: fontFamily)),+ title: Text('分片并发数'),description: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [Text('每集同时下载 $parallelSegments 个分片',- style: TextStyle(fontFamily: fontFamily),),Slider(value: parallelSegments.toDouble(),@@ -172,10 +169,10 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {],),SettingsSection(- title: Text('缓存设置', style: TextStyle(fontFamily: fontFamily)),+ title: Text('缓存设置'),tiles: [SettingsTile(- title: Text('下载位置', style: TextStyle(fontFamily: fontFamily)),+ title: Text('下载位置'),description: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [@@ -183,7 +180,6 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {_effectiveDownloadDirectory.isEmpty? '正在读取默认位置...': _effectiveDownloadDirectory,- style: TextStyle(fontFamily: fontFamily),),const SizedBox(height: 8),Text(@@ -192,7 +188,6 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {: '当前使用默认下载位置,修改后仅对新下载生效',style: TextStyle(color: Theme.of(context).textTheme.bodySmall?.color,- fontFamily: fontFamily,),),],@@ -218,26 +213,24 @@ class _DownloadSettingsPageState extends State<DownloadSettingsPage> {GStorage.putSetting(SettingsKeys.downloadDanmaku, downloadDanmaku);},- title: Text('缓存弹幕', style: TextStyle(fontFamily: fontFamily)),+ title: Text('缓存弹幕'),description: Text('下载视频时同时缓存弹幕数据',- style: TextStyle(fontFamily: fontFamily),),initialValue: downloadDanmaku,),],),SettingsSection(- title: Text('说明', style: TextStyle(fontFamily: fontFamily)),+ title: Text('说明'),tiles: [SettingsTile(- title: Text('关于并发设置', style: TextStyle(fontFamily: fontFamily)),+ title: Text('关于并发设置'),description: Text('• 集数并发:同时下载多少集视频\n''• 分片并发:每集内同时下载多少个视频片段\n''• 较高的并发可提升速度,但可能被服务器限制\n''• 修改后对新开始的下载生效',- style: TextStyle(fontFamily: fontFamily),),),],diff --git a/lib/pages/settings/interface_settings.dart b/lib/pages/settings/interface_settings.dartindex 1e6a151e..4cb8a045 100644--- a/lib/pages/settings/interface_settings.dart+++ b/lib/pages/settings/interface_settings.dart@@ -1,8 +1,6 @@-import 'package:card_settings_ui/list/settings_list.dart';-import 'package:card_settings_ui/section/settings_section.dart';-import 'package:card_settings_ui/tile/settings_tile.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:flutter/material.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/services/storage/storage.dart';class InterfaceSettingsPage extends StatefulWidget {@@ -42,16 +40,12 @@ class _InterfaceSettingsPageState extends State<InterfaceSettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;-- return Scaffold(- appBar: SysAppBar(- title: Text('界面设置'),- ),+ return SettingsDetailScaffold(+ title: Text('界面设置'),body: SettingsList(sections: [SettingsSection(tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {if (defaultPageMenuController.isOpen) {defaultPageMenuController.close();@@ -59,16 +53,14 @@ class _InterfaceSettingsPageState extends State<InterfaceSettingsPage> {defaultPageMenuController.open();}},- title: Text('启动界面设置', style: TextStyle(fontFamily: fontFamily)),- description: Text('设置应用开启时的默认页面',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('启动界面设置'),+ description: Text('设置应用开启时的默认页面'),value: MenuAnchor(consumeOutsideTap: true,controller: defaultPageMenuController,builder: (_, __, ___) {return Text(defaultPageMap[defaultPage] ?? '推荐',- style: TextStyle(fontFamily: fontFamily),);},menuChildren: [@@ -87,7 +79,6 @@ class _InterfaceSettingsPageState extends State<InterfaceSettingsPage> {color: entry.key == defaultPage? Theme.of(context).colorScheme.primary: null,- fontFamily: fontFamily,),),),@@ -104,9 +95,8 @@ class _InterfaceSettingsPageState extends State<InterfaceSettingsPage> {await GStorage.putSetting(SettingsKeys.showRating, showRating);setState(() {});},- title: Text('显示评分', style: TextStyle(fontFamily: fontFamily)),- description: Text('关闭后将在概览中隐藏评分信息',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('显示评分'),+ description: Text('关闭后将在概览中隐藏评分信息'),initialValue: showRating,),]),@@ -114,12 +104,12 @@ class _InterfaceSettingsPageState extends State<InterfaceSettingsPage> {SettingsTile.switchTile(onToggle: (value) async {showAnimeCounter = value ?? !showAnimeCounter;- await GStorage.putSetting(SettingsKeys.showAnimeCounter, showAnimeCounter);+ await GStorage.putSetting(+ SettingsKeys.showAnimeCounter, showAnimeCounter);setState(() {});},- title: Text('显示追番统计', style: TextStyle(fontFamily: fontFamily)),- description: Text('启用后将在追番页面下方显示追番统计',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('显示追番统计'),+ description: Text('启用后将在追番页面下方显示追番统计'),initialValue: showAnimeCounter,),]),diff --git a/lib/pages/settings/keyboard_settings.dart b/lib/pages/settings/keyboard_settings.dartindex 0385176e..c1a2731b 100644--- a/lib/pages/settings/keyboard_settings.dart+++ b/lib/pages/settings/keyboard_settings.dart@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/utils/constants.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';/// Display group for the shortcut list. Functions missing from every group@@ -217,17 +217,15 @@ class _KeyboardSettingsPageState extends State<KeyboardSettingsPage> {final colorScheme = Theme.of(context).colorScheme;final textTheme = Theme.of(context).textTheme;- return Scaffold(- appBar: SysAppBar(- title: const Text('操作设置'),- actions: [- IconButton(- icon: const Icon(Icons.settings_backup_restore_rounded),- tooltip: '恢复默认',- onPressed: restoreDefaults,- ),- ],- ),+ return SettingsDetailScaffold(+ title: const Text('操作设置'),+ actions: [+ IconButton(+ icon: const Icon(Icons.settings_backup_restore_rounded),+ tooltip: '恢复默认',+ onPressed: restoreDefaults,+ ),+ ],body: FocusScope(autofocus: true,child: Focus(@@ -311,8 +309,8 @@ class _KeyboardSettingsPageState extends State<KeyboardSettingsPage> {const SizedBox(width: 12),Text(group.title,- style:- textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),+ style: textTheme.titleMedium+ ?.copyWith(fontWeight: FontWeight.w700),),],),@@ -361,9 +359,8 @@ class _KeyboardSettingsPageState extends State<KeyboardSettingsPage> {label: listening ? '按任意键' : keyAliases[keys[i]] ?? keys[i],listening: listening,onTap: () => onKeyCapTap(func, i),- onDelete: realCount >= 2 && !listening- ? () => onRemoveKey(func, i)- : null,+ onDelete:+ realCount >= 2 && !listening ? () => onRemoveKey(func, i) : null,);}}diff --git a/lib/pages/settings/player_settings.dart b/lib/pages/settings/player_settings.dartindex 15dd0813..7d9e0e21 100644--- a/lib/pages/settings/player_settings.dart+++ b/lib/pages/settings/player_settings.dart@@ -3,13 +3,13 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart' show FilteringTextInputFormatter;import 'package:flutter_modular/flutter_modular.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/pages/player/controller/player_aspect_ratio.dart';import 'package:kazumi/services/network/metered_network_service.dart';import 'package:kazumi/utils/constants.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/services/player/pip_utils.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:kazumi/utils/device.dart';class PlayerSettingsPage extends StatefulWidget {@@ -265,14 +265,13 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: true,onPopInvokedWithResult: (bool didPop, Object? result) {onBackPressed(context);},- child: Scaffold(- appBar: const SysAppBar(title: Text('播放设置')),+ child: SettingsDetailScaffold(+ title: const Text('播放设置'),body: SettingsList(maxWidth: 1000,sections: [@@ -285,27 +284,23 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.hAenable, hAenable);setState(() {});},- title: Text('硬件解码', style: TextStyle(fontFamily: fontFamily)),+ title: Text('硬件解码'),initialValue: hAenable,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {await context.pushNamed('/settings/player/decoder');},- title:- Text('硬件解码器', style: TextStyle(fontFamily: fontFamily)),- description: Text('仅在硬件解码启用时生效',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('硬件解码器'),+ description: Text('仅在硬件解码启用时生效'),),if (Platform.isAndroid) ...[- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {await context.pushNamed('/settings/player/renderer');},- title:- Text('视频渲染器', style: TextStyle(fontFamily: fontFamily)),- description: Text('选择视频输出方式',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('视频渲染器'),+ description: Text('选择视频输出方式'),),],SettingsTile.switchTile(@@ -316,13 +311,10 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.lowMemoryMode, lowMemoryMode);setState(() {});},- title:- Text('低内存模式', style: TextStyle(fontFamily: fontFamily)),- description: Text(- MeteredNetworkService.isMetered- ? '移动网络下已自动启用'- : '禁用高级缓存以减少内存占用',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('低内存模式'),+ description: Text(MeteredNetworkService.isMetered+ ? '移动网络下已自动启用'+ : '禁用高级缓存以减少内存占用'),// Effective state, not the stored one, which stays untouched.initialValue:lowMemoryMode || MeteredNetworkService.isMetered,@@ -336,18 +328,16 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {androidEnableOpenSLES);setState(() {});},- title:- Text('低延迟音频', style: TextStyle(fontFamily: fontFamily)),- description: Text('启用OpenSLES音频输出以降低延时',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('低延迟音频'),+ description: Text('启用OpenSLES音频输出以降低延时'),initialValue: androidEnableOpenSLES,),],- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {context.pushNamed('/settings/player/super');},- title: Text('超分辨率', style: TextStyle(fontFamily: fontFamily)),+ title: Text('超分辨率'),),],),@@ -360,9 +350,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.backgroundPlayback, backgroundPlayback);setState(() {});},- title: Text('后台播放', style: TextStyle(fontFamily: fontFamily)),- description: Text('应用退到后台或熄屏时继续播放音频',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('后台播放'),+ description: Text('应用退到后台或熄屏时继续播放音频'),initialValue: backgroundPlayback,),SettingsTile.switchTile(@@ -372,9 +361,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.playResume, playResume);setState(() {});},- title: Text('自动跳转', style: TextStyle(fontFamily: fontFamily)),- description: Text('跳转到上次播放位置',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('自动跳转'),+ description: Text('跳转到上次播放位置'),initialValue: playResume,),SettingsTile.switchTile(@@ -384,9 +372,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.autoPlayNext, autoPlayNext);setState(() {});},- title: Text('自动连播', style: TextStyle(fontFamily: fontFamily)),- description: Text('当前视频播放完毕后自动播放下一集',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('自动连播'),+ description: Text('当前视频播放完毕后自动播放下一集'),initialValue: autoPlayNext,),if (Platform.isAndroid)@@ -400,10 +387,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {androidAutoEnterPIP);setState(() {});},- title: Text('自动进入画中画',- style: TextStyle(fontFamily: fontFamily)),- description: Text('切到后台时,自动进入画中画',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('自动进入画中画'),+ description: Text('切到后台时,自动进入画中画'),initialValue: androidAutoEnterPIP,),SettingsTile.switchTile(@@ -413,9 +398,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.forceAdBlocker, forceAdBlocker);setState(() {});},- title: Text('广告过滤', style: TextStyle(fontFamily: fontFamily)),- description: Text('强制启用HLS广告过滤,忽略规则设置',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('广告过滤'),+ description: Text('强制启用HLS广告过滤,忽略规则设置'),initialValue: forceAdBlocker,),SettingsTile.switchTile(@@ -426,9 +410,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {playerDisableAnimations);setState(() {});},- title: Text('禁用动画', style: TextStyle(fontFamily: fontFamily)),- description: Text('禁用播放器内的过渡动画',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('禁用动画'),+ description: Text('禁用播放器内的过渡动画'),initialValue: playerDisableAnimations,),if (!isDesktop())@@ -441,10 +424,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {brightnessVolumeGesture);setState(() {});},- title:- Text('滑动手势', style: TextStyle(fontFamily: fontFamily)),- description: Text('竖向滑动调节音量和亮度',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('滑动手势'),+ description: Text('竖向滑动调节音量和亮度'),initialValue: brightnessVolumeGesture,),SettingsTile.switchTile(@@ -454,9 +435,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.privateMode, privateMode);setState(() {});},- title: Text('隐身模式', style: TextStyle(fontFamily: fontFamily)),- description:- Text('不保留观看记录', style: TextStyle(fontFamily: fontFamily)),+ title: Text('隐身模式'),+ description: Text('不保留观看记录'),initialValue: privateMode,),],@@ -470,9 +450,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.showPlayerError, showPlayerError);setState(() {});},- title: Text('错误提示', style: TextStyle(fontFamily: fontFamily)),- description: Text('显示播放器内部错误提示',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('错误提示'),+ description: Text('显示播放器内部错误提示'),initialValue: showPlayerError,),SettingsTile.switchTile(@@ -482,12 +461,11 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsKeys.playerDebugMode, playerDebugMode);setState(() {});},- title: Text('调试模式', style: TextStyle(fontFamily: fontFamily)),- description: Text('记录播放器内部日志',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('调试模式'),+ description: Text('记录播放器内部日志'),initialValue: playerDebugMode,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {if (playerLogLevelMenuController.isOpen) {playerLogLevelMenuController.close();@@ -495,9 +473,8 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {playerLogLevelMenuController.open();}},- title: Text('日志等级', style: TextStyle(fontFamily: fontFamily)),- description: Text('播放器内部日志等级',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('日志等级'),+ description: Text('播放器内部日志等级'),value: MenuAnchor(consumeOutsideTap: true,controller: playerLogLevelMenuController,@@ -535,7 +512,7 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {SettingsSection(tiles: [SettingsTile(- title: Text('默认倍速', style: TextStyle(fontFamily: fontFamily)),+ title: Text('默认倍速'),description: Slider(value: defaultPlaySpeed,min: 0.25,@@ -549,8 +526,7 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {),),SettingsTile(- title: Text('默认方向键/长按倍速',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('默认方向键/长按倍速'),description: Slider(value: defaultShortcutForwardPlaySpeed,min: 1.25,@@ -563,7 +539,7 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {},),),- SettingsTile.navigation(+ SettingsTile(description: Slider(value: playerArrowKeySkipTime.toDouble(),min: 0,@@ -582,23 +558,19 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {}},),- title: Text('左右方向键的快进/快退秒数',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('左右方向键的快进/快退秒数'),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {await updateButtonSkipTime();},- title: Text('跳过时长', style: TextStyle(fontFamily: fontFamily)),- description: Text('顶栏跳过按钮的秒数',- style: TextStyle(fontFamily: fontFamily)),- value: Text('$playerButtonSkipTime 秒',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('跳过时长'),+ description: Text('顶栏跳过按钮的秒数'),+ value: Text('$playerButtonSkipTime 秒'),),SettingsTile(title: Text(- '播放控制器消失时间:${formatPlayerControllerLayerDisappearSeconds(playerControllerLayerDisappearSeconds)}',- style: TextStyle(fontFamily: fontFamily)),+ '播放控制器消失时间:${formatPlayerControllerLayerDisappearSeconds(playerControllerLayerDisappearSeconds)}'),description: Slider(value: playerControllerLayerDisappearSeconds,min: _minPlayerControllerLayerDisappearSeconds,@@ -609,7 +581,7 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {onChanged: updatePlayerControllerLayerDisappearSeconds,),),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {if (playerAspectRatioMenuController.isOpen) {playerAspectRatioMenuController.close();@@ -617,15 +589,13 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {playerAspectRatioMenuController.open();}},- title:- Text('默认视频比例', style: TextStyle(fontFamily: fontFamily)),+ title: Text('默认视频比例'),value: MenuAnchor(consumeOutsideTap: true,controller: playerAspectRatioMenuController,builder: (_, __, ___) {return Text(defaultAspectRatioMode.label,- style: TextStyle(fontFamily: fontFamily),);},menuChildren: [@@ -646,7 +616,6 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {defaultAspectRatioMode? Theme.of(context).colorScheme.primary: null,- fontFamily: fontFamily,),),),@@ -659,12 +628,10 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {),SettingsSection(tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) => resetPlayerSettings(),- title:- Text('恢复默认设置', style: TextStyle(fontFamily: fontFamily)),- description: Text('将播放相关设置恢复为默认值',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('恢复默认设置'),+ description: Text('将播放相关设置恢复为默认值'),),],),diff --git a/lib/pages/settings/proxy/proxy_settings_page.dart b/lib/pages/settings/proxy/proxy_settings_page.dartindex 945b1810..6c7aa00f 100644--- a/lib/pages/settings/proxy/proxy_settings_page.dart+++ b/lib/pages/settings/proxy/proxy_settings_page.dart@@ -1,10 +1,10 @@import 'package:flutter/material.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:flutter_modular/flutter_modular.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/services/network/proxy_manager.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';class ProxySettingsPage extends StatefulWidget {const ProxySettingsPage({super.key});@@ -49,30 +49,28 @@ class _ProxySettingsPageState extends State<ProxySettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: true,onPopInvokedWithResult: (bool didPop, Object? result) {onBackPressed(context);},- child: Scaffold(- appBar: const SysAppBar(title: Text('代理设置')),+ child: SettingsDetailScaffold(+ title: const Text('代理设置'),body: SettingsList(maxWidth: 800,sections: [SettingsSection(- title: Text('代理', style: TextStyle(fontFamily: fontFamily)),+ title: Text('代理'),tiles: [SettingsTile.switchTile(onToggle: (value) async {await updateProxyEnable(value ?? !proxyEnable);},- title: Text('启用代理', style: TextStyle(fontFamily: fontFamily)),- description: Text('启用后网络请求将通过代理服务器',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('启用代理'),+ description: Text('启用后网络请求将通过代理服务器'),initialValue: proxyEnable,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {await context.pushNamed('/settings/proxy/editor');setState(() {@@ -80,9 +78,8 @@ class _ProxySettingsPageState extends State<ProxySettingsPage> {GStorage.getSetting(SettingsKeys.proxyEnable);});},- title: Text('代理配置', style: TextStyle(fontFamily: fontFamily)),- description: Text('配置代理服务器地址和认证信息',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('代理配置'),+ description: Text('配置代理服务器地址和认证信息'),),],),diff --git a/lib/pages/settings/renderer_settings.dart b/lib/pages/settings/renderer_settings.dartindex 290faf7c..2283a3ac 100644--- a/lib/pages/settings/renderer_settings.dart+++ b/lib/pages/settings/renderer_settings.dart@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/utils/constants.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';class RendererSettings extends StatefulWidget {const RendererSettings({super.key});@@ -24,7 +24,6 @@ class _RendererSettingsState extends State<RendererSettings> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return Scaffold(appBar: const SysAppBar(title: Text('视频渲染器'),@@ -32,26 +31,23 @@ class _RendererSettingsState extends State<RendererSettings> {body: SettingsList(maxWidth: 1000,sections: [- SettingsSection(- title: Text('选择合适的渲染器以获得最佳播放体验',- style: TextStyle(fontFamily: fontFamily)),+ SettingsRadioSection<String>(+ title: Text('选择合适的渲染器以获得最佳播放体验'),+ groupValue: renderer.value,+ onChanged: (String? value) {+ if (value != null) {+ GStorage.putSetting<String>(+ SettingsKeys.androidVideoRenderer, value);+ setState(() {+ renderer.value = value;+ });+ }+ },tiles: androidVideoRenderersList.entries.map((e) => SettingsTile<String>.radioTile(- title:- Text(e.key, style: TextStyle(fontFamily: fontFamily)),- description: Text(e.value,- style: TextStyle(fontFamily: fontFamily)),+ title: Text(e.key),+ description: Text(e.value),radioValue: e.key,- groupValue: renderer.value,- onChanged: (String? value) {- if (value != null) {- GStorage.putSetting<String>(- SettingsKeys.androidVideoRenderer, value);- setState(() {- renderer.value = value;- });- }- },)).toList(),),diff --git a/lib/pages/settings/settings_module.dart b/lib/pages/settings/settings_module.dartindex eba481aa..43a44782 100644--- a/lib/pages/settings/settings_module.dart+++ b/lib/pages/settings/settings_module.dart@@ -13,6 +13,7 @@ import 'package:kazumi/pages/settings/keyboard_settings.dart';import 'package:kazumi/pages/settings/player_settings.dart';import 'package:kazumi/pages/settings/proxy/proxy_module.dart';import 'package:kazumi/pages/settings/renderer_settings.dart';+import 'package:kazumi/pages/settings/settings_page.dart';import 'package:kazumi/pages/settings/super_resolution_settings.dart';import 'package:kazumi/pages/settings/theme_settings_page.dart';import 'package:kazumi/pages/webdav_editor/webdav_module.dart';@@ -21,6 +22,7 @@ final settingsModule = createModule(path: '/settings',register: (c) {c+ ..route('/', child: (context, state) => const SettingsPage())..route('/theme', child: (context, state) => const ThemeSettingsPage())..route('/theme/display',diff --git a/lib/pages/settings/settings_page.dart b/lib/pages/settings/settings_page.dartnew file mode 100644index 00000000..145431f8--- /dev/null+++ b/lib/pages/settings/settings_page.dart@@ -0,0 +1,491 @@+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/settings/settings_detail_scaffold.dart';+import 'package:kazumi/pages/about/about_page.dart';+import 'package:kazumi/pages/my/my_controller.dart';+import 'package:kazumi/pages/plugin_editor/plugin_view_page.dart';+import 'package:kazumi/pages/settings/danmaku/danmaku_settings.dart';+import 'package:kazumi/pages/settings/download_settings.dart';+import 'package:kazumi/pages/settings/interface_settings.dart';+import 'package:kazumi/pages/settings/keyboard_settings.dart';+import 'package:kazumi/pages/settings/player_settings.dart';+import 'package:kazumi/pages/settings/proxy/proxy_settings_page.dart';+import 'package:kazumi/pages/settings/theme_settings_page.dart';+import 'package:kazumi/pages/webdav_editor/webdav_setting.dart';+import 'package:kazumi/plugins/plugins_controller.dart';+import 'package:kazumi/utils/constants.dart';++class _SettingsCategory {+ const _SettingsCategory({+ required this.id,+ required this.label,+ required this.description,+ required this.icon,+ required this.builder,+ });++ final String id;+ final String label;+ final String description;+ final IconData icon;+ final WidgetBuilder builder;+}++class _SettingsGroup {+ const _SettingsGroup({required this.title, required this.categories});++ final String title;+ final List<_SettingsCategory> categories;+}++final List<_SettingsGroup> _settingsGroups = [+ _SettingsGroup(+ title: '播放',+ categories: [+ _SettingsCategory(+ id: 'player',+ label: '播放设置',+ description: '解码、渲染与播放行为',+ icon: Icons.display_settings_rounded,+ builder: (_) => const PlayerSettingsPage(),+ ),+ _SettingsCategory(+ id: 'danmaku',+ label: '弹幕设置',+ description: '弹幕来源与显示效果',+ icon: Icons.subtitles_rounded,+ builder: (_) => const DanmakuSettingsPage(),+ ),+ _SettingsCategory(+ id: 'keyboard',+ label: '操作设置',+ description: '播放器按键映射',+ icon: Icons.keyboard_rounded,+ builder: (_) => const KeyboardSettingsPage(),+ ),+ ],+ ),+ _SettingsGroup(+ title: '资源',+ categories: [+ _SettingsCategory(+ id: 'plugin',+ label: '规则管理',+ description: '番剧资源规则',+ icon: Icons.extension_rounded,+ builder: (_) => PluginViewPage(controller: inject<PluginsController>()),+ ),+ _SettingsCategory(+ id: 'download',+ label: '下载设置',+ description: '并发数与弹幕缓存',+ icon: Icons.downloading_rounded,+ builder: (_) => const DownloadSettingsPage(),+ ),+ ],+ ),+ _SettingsGroup(+ title: '应用',+ categories: [+ _SettingsCategory(+ id: 'theme',+ label: '外观设置',+ description: '主题、配色与字体',+ icon: Icons.palette_rounded,+ builder: (_) => const ThemeSettingsPage(),+ ),+ _SettingsCategory(+ id: 'interface',+ label: '界面设置',+ description: '启动页与展示信息',+ icon: Icons.pages_rounded,+ builder: (_) => const InterfaceSettingsPage(),+ ),+ _SettingsCategory(+ id: 'sync',+ label: '同步设置',+ description: 'WebDav 与 Bangumi 同步',+ icon: Icons.cloud_rounded,+ builder: (_) => const WebDavSettingsPage(),+ ),+ _SettingsCategory(+ id: 'proxy',+ label: '代理设置',+ description: 'HTTP 代理服务器',+ icon: Icons.vpn_key_rounded,+ builder: (_) => const ProxySettingsPage(),+ ),+ ],+ ),+ _SettingsGroup(+ title: '其他',+ categories: [+ _SettingsCategory(+ id: 'about',+ label: '关于',+ description: '版本、日志与开源许可',+ icon: Icons.info_outline_rounded,+ builder: (_) => AboutPage(controller: inject<MyController>()),+ ),+ ],+ ),+];++/// Adds and removes pages without a transition, so a breakpoint reflow is+/// carried by the rail animation alone instead of two animations at once.+class _InstantTransitionDelegate extends TransitionDelegate<dynamic> {+ const _InstantTransitionDelegate();++ @override+ Iterable<RouteTransitionRecord> resolve({+ required List<RouteTransitionRecord> newPageRouteHistory,+ required Map<RouteTransitionRecord?, RouteTransitionRecord>+ locationToExitingPageRoute,+ required Map<RouteTransitionRecord?, List<RouteTransitionRecord>>+ pageRouteToPagelessRoutes,+ }) {+ final results = <RouteTransitionRecord>[];+ for (final pageRoute in newPageRouteHistory) {+ if (pageRoute.isWaitingForEnteringDecision) {+ pageRoute.markForAdd();+ }+ results.add(pageRoute);+ }+ for (final exitingPageRoute in locationToExitingPageRoute.values) {+ if (exitingPageRoute.isWaitingForExitingDecision) {+ exitingPageRoute.markForComplete();+ final pagelessRoutes = pageRouteToPagelessRoutes[exitingPageRoute];+ if (pagelessRoutes != null) {+ for (final pagelessRoute in pagelessRoutes) {+ pagelessRoute.markForComplete();+ }+ }+ }+ results.add(exitingPageRoute);+ }+ return results;+ }+}++class SettingsPage extends StatefulWidget {+ const SettingsPage({super.key});++ @override+ State<SettingsPage> createState() => _SettingsPageState();+}++class _SettingsPageState extends State<SettingsPage> {+ static const Duration _paneMotion = Duration(milliseconds: 250);+ static const double _railWidth = 280;+ static const ValueKey<String> _listPageKey =+ ValueKey<String>('settings-list');++ /// Single-pane detail rides a real route so it keeps the platform transition.+ final GlobalKey<NavigatorState> _detailNavigatorKey =+ GlobalKey<NavigatorState>();++ /// Single source of truth for the layout: it picks the right pane's content+ /// in two-pane mode and whether the detail route is pushed in single-pane,+ /// so resizing across the breakpoint reflows without losing the selection.+ _SettingsCategory? _selected;++ bool? _lastTwoPane;++ bool _useTwoPane(BuildContext context) {+ return MediaQuery.orientationOf(context) == Orientation.landscape &&+ MediaQuery.sizeOf(context).width > LayoutBreakpoint.compact['width']!;+ }++ void _backToCategoryList() {+ setState(() => _selected = null);+ }++ @override+ Widget build(BuildContext context) {+ final twoPane = _useTwoPane(context);+ // Falls back to the first category without writing it back, otherwise+ // narrowing the window would jump into a category never picked.+ final shown = _selected ?? _settingsGroups.first.categories.first;+ final detail = twoPane ? null : _selected;+ final layoutChanged = _lastTwoPane != null && _lastTwoPane != twoPane;+ _lastTwoPane = twoPane;++ return NavigatorPopHandler(+ onPopWithResult: (_) => _detailNavigatorKey.currentState?.maybePop(),+ child: Navigator(+ key: _detailNavigatorKey,+ transitionDelegate: layoutChanged+ ? const _InstantTransitionDelegate()+ : const DefaultTransitionDelegate<dynamic>(),+ onDidRemovePage: (page) {+ // A layout-driven removal keeps the selection for the right pane.+ if (page.key != _listPageKey && !_useTwoPane(context)) {+ _backToCategoryList();+ }+ },+ pages: [+ MaterialPage(+ key: _listPageKey,+ child: _listScaffold(context, twoPane, shown),+ ),+ if (detail != null)+ MaterialPage(+ key: ValueKey<String>('settings-detail:${detail.id}'),+ child: SettingsPaneScope(+ embedded: false,+ onBack: _backToCategoryList,+ child: Builder(builder: detail.builder),+ ),+ ),+ ],+ ),+ );+ }++ Widget _listScaffold(+ BuildContext context,+ bool twoPane,+ _SettingsCategory shown,+ ) {+ return Scaffold(+ appBar: SysAppBar(+ title: const Text('设置'),+ // First route of the nested Navigator, so back must pop the outer one.+ leading: IconButton(+ onPressed: () => context.maybePop(),+ icon: const Icon(Icons.arrow_back),+ ),+ ),+ body: SafeArea(+ top: false,+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ ClipRect(+ child: AnimatedAlign(+ duration: _paneMotion,+ curve: Curves.easeInOutCubic,+ alignment: Alignment.centerLeft,+ widthFactor: twoPane ? 1 : 0,+ child: SizedBox(+ width: _railWidth,+ child: _rail(context, shown),+ ),+ ),+ ),+ Expanded(+ child: AnimatedSwitcher(+ duration: _paneMotion,+ switchInCurve: Curves.easeInOutCubic,+ switchOutCurve: Curves.easeInOutCubic,+ child: twoPane+ ? _detailPane(context, shown)+ : KeyedSubtree(+ key: const ValueKey<String>('categories'),+ child: _singlePaneBody(context),+ ),+ ),+ ),+ ],+ ),+ ),+ );+ }++ /// Left unfilled so the pane shares the page surface; a fill would either+ /// match the cards inside it or stack another tone step onto them.+ Widget _detailPane(BuildContext context, _SettingsCategory shown) {+ return Padding(+ key: ValueKey<String>('pane:${shown.id}'),+ padding: const EdgeInsets.fromLTRB(8, 0, 12, 0),+ child: _withoutScrollbar(+ context,+ SettingsPaneScope(+ embedded: true,+ child: Builder(builder: shown.builder),+ ),+ ),+ );+ }++ /// Scoped so the lists inside each embedded settings page are covered too.+ Widget _withoutScrollbar(BuildContext context, Widget child) {+ return ScrollConfiguration(+ behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),+ child: child,+ );+ }++ Widget _rail(BuildContext context, _SettingsCategory shown) {+ final textTheme = Theme.of(context).textTheme;+ final colorScheme = Theme.of(context).colorScheme;+ return _withoutScrollbar(+ context,+ ListView(+ padding: const EdgeInsets.fromLTRB(4, 0, 0, 12),+ children: [+ for (final group in _settingsGroups) ...[+ Padding(+ padding: const EdgeInsets.fromLTRB(28, 16, 28, 8),+ child: Text(+ group.title,+ style: textTheme.titleSmall+ ?.copyWith(color: colorScheme.onSurfaceVariant),+ ),+ ),+ for (final category in group.categories)+ _RailDestination(+ category: category,+ selected: category.id == shown.id,+ onTap: () => setState(() => _selected = category),+ ),+ ],+ ],+ ),+ );+ }++ Widget _singlePaneBody(BuildContext context) {+ final textTheme = Theme.of(context).textTheme;+ final colorScheme = Theme.of(context).colorScheme;+ return ListView(+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),+ children: [+ for (final group in _settingsGroups) ...[+ Padding(+ padding: const EdgeInsets.fromLTRB(4, 16, 4, 8),+ child: Text(+ group.title,+ style: textTheme.titleSmall+ ?.copyWith(color: colorScheme.onSurfaceVariant),+ ),+ ),+ Material(+ // Material, not Container, so the ink ripple paints above the fill.+ color: colorScheme.surfaceContainerLow,+ borderRadius: BorderRadius.circular(16),+ clipBehavior: Clip.antiAlias,+ child: Column(+ children: [+ for (final category in group.categories)+ _CategoryTile(+ category: category,+ onTap: () => setState(() => _selected = category),+ ),+ ],+ ),+ ),+ ],+ ],+ );+ }+}++class _RailDestination extends StatelessWidget {+ const _RailDestination({+ required this.category,+ required this.selected,+ required this.onTap,+ });++ final _SettingsCategory category;+ final bool selected;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ final foreground = selected+ ? colorScheme.onSecondaryContainer+ : colorScheme.onSurfaceVariant;+ return Padding(+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),+ child: Material(+ color: selected ? colorScheme.secondaryContainer : Colors.transparent,+ borderRadius: BorderRadius.circular(28),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ onTap: onTap,+ child: SizedBox(+ height: 56,+ child: Row(+ children: [+ const SizedBox(width: 16),+ Icon(category.icon, size: 24, color: foreground),+ const SizedBox(width: 12),+ Expanded(+ child: Text(+ category.label,+ style: textTheme.labelLarge?.copyWith(color: foreground),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ const SizedBox(width: 12),+ ],+ ),+ ),+ ),+ ),+ );+ }+}++class _CategoryTile extends StatelessWidget {+ const _CategoryTile({required this.category, required this.onTap});++ final _SettingsCategory category;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ return InkWell(+ onTap: onTap,+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),+ child: Row(+ children: [+ Container(+ width: 36,+ height: 36,+ decoration: BoxDecoration(+ color: colorScheme.secondaryContainer,+ shape: BoxShape.circle,+ ),+ child: Icon(+ category.icon,+ size: 18,+ color: colorScheme.onSecondaryContainer,+ ),+ ),+ const SizedBox(width: 16),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(category.label, style: textTheme.bodyLarge),+ const SizedBox(height: 2),+ Text(+ category.description,+ style: textTheme.bodySmall+ ?.copyWith(color: colorScheme.onSurfaceVariant),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),+ ),+ Icon(+ Icons.chevron_right_rounded,+ color: colorScheme.onSurfaceVariant,+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/lib/pages/settings/super_resolution_settings.dart b/lib/pages/settings/super_resolution_settings.dartindex 5c114534..e0724d39 100644--- a/lib/pages/settings/super_resolution_settings.dart+++ b/lib/pages/settings/super_resolution_settings.dart@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/pages/player/controller/player_super_resolution.dart';import 'package:kazumi/services/storage/storage.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_list.dart';class SuperResolutionSettings extends StatefulWidget {const SuperResolutionSettings({super.key});@@ -29,7 +29,6 @@ class _SuperResolutionSettingsState extends State<SuperResolutionSettings> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return Scaffold(appBar: const SysAppBar(title: Text('超分辨率'),@@ -37,41 +36,34 @@ class _SuperResolutionSettingsState extends State<SuperResolutionSettings> {body: SettingsList(maxWidth: 1000,sections: [+ SettingsRadioSection<SuperResolutionMode>(+ title: Text('超分辨率需要启用硬件解码, 若启用硬件解码后仍然不生效, 尝试切换视频渲染器为 gpu'),+ groupValue: superResolutionMode,+ onChanged: (SuperResolutionMode? value) {+ if (value == null) return;+ GStorage.putSetting<int>(+ SettingsKeys.defaultSuperResolutionMode,+ value.storageValue,+ );+ setState(() {+ superResolutionMode = value;+ });+ },+ tiles: [+ for (final mode in SuperResolutionMode.values)+ SettingsTile<SuperResolutionMode>.radioTile(+ title: Text(mode.label),+ description: Text(mode.description),+ radioValue: mode,+ ),+ ],+ ),SettingsSection(- title: Text('超分辨率需要启用硬件解码, 若启用硬件解码后仍然不生效, 尝试切换视频渲染器为 gpu',- style: TextStyle(fontFamily: fontFamily)),- tiles: [- for (final mode in SuperResolutionMode.values)- SettingsTile<SuperResolutionMode>.radioTile(- title: Text(- mode.label,- style: TextStyle(fontFamily: fontFamily),- ),- description: Text(- mode.description,- style: TextStyle(fontFamily: fontFamily),- ),- radioValue: mode,- groupValue: superResolutionMode,- onChanged: (SuperResolutionMode? value) {- if (value == null) return;- GStorage.putSetting<int>(- SettingsKeys.defaultSuperResolutionMode,- value.storageValue,- );- setState(() {- superResolutionMode = value;- });- },- ),- ]),- SettingsSection(- title: Text('默认行为', style: TextStyle(fontFamily: fontFamily)),+ title: Text('默认行为'),tiles: [SettingsTile.switchTile(- title: Text('关闭提示', style: TextStyle(fontFamily: fontFamily)),- description: Text('关闭每次启用超分辨率时的提示',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('关闭提示'),+ description: Text('关闭每次启用超分辨率时的提示'),initialValue: disableWarning,onToggle: (value) async {disableWarning = value ?? !disableWarning;diff --git a/lib/pages/settings/theme_settings_page.dart b/lib/pages/settings/theme_settings_page.dartindex b583f06f..8c3cffbd 100644--- a/lib/pages/settings/theme_settings_page.dart+++ b/lib/pages/settings/theme_settings_page.dart@@ -6,9 +6,9 @@ import 'package:kazumi/utils/constants.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/bean/dialog/dialog_helper.dart';import 'package:kazumi/bean/settings/theme_provider.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';import 'package:kazumi/bean/settings/color_type.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';+import 'package:kazumi/bean/settings/settings_list.dart';import 'package:window_manager/window_manager.dart';import 'package:kazumi/utils/device.dart';import 'package:kazumi/utils/theme.dart';@@ -135,21 +135,20 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: true,onPopInvokedWithResult: (bool didPop, Object? result) {onBackPressed(context);},- child: Scaffold(- appBar: const SysAppBar(title: Text('外观设置')),+ child: SettingsDetailScaffold(+ title: const Text('外观设置'),body: SettingsList(maxWidth: 1000,sections: [SettingsSection(- title: Text('外观', style: TextStyle(fontFamily: fontFamily)),+ title: Text('外观'),tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) {if (menuController.isOpen) {menuController.close();@@ -157,7 +156,7 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {menuController.open();}},- title: Text('深色模式', style: TextStyle(fontFamily: fontFamily)),+ title: Text('深色模式'),value: MenuAnchor(consumeOutsideTap: true,controller: menuController,@@ -166,7 +165,6 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {defaultThemeMode == 'light'? '浅色': (defaultThemeMode == 'dark' ? '深色' : '跟随系统'),- style: TextStyle(fontFamily: fontFamily),);},menuChildren: [@@ -193,7 +191,6 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {color: defaultThemeMode == 'system'? Theme.of(context).colorScheme.primary: null,- fontFamily: fontFamily,),),],@@ -225,8 +222,7 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {? Theme.of(context).colorScheme.primary- : null,- fontFamily: fontFamily),+ : null),),],),@@ -256,7 +252,6 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {color: defaultThemeMode == 'dark'? Theme.of(context).colorScheme.primary: null,- fontFamily: fontFamily,),),],@@ -267,13 +262,12 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {],),),- SettingsTile.navigation(+ SettingsTile(enabled: !useDynamicColor,onPressed: (_) async {KazumiDialog.show(builder: (context) {return AlertDialog(- title: Text('配色方案',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('配色方案'),content: StatefulBuilder(builder:(BuildContext context, StateSetter setState) {final List<Map<String, dynamic>> colorThemes =@@ -316,7 +310,7 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {);});},- title: Text('配色方案', style: TextStyle(fontFamily: fontFamily)),+ title: Text('配色方案'),),SettingsTile.switchTile(enabled: !Platform.isIOS,@@ -327,7 +321,7 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {themeProvider.setDynamic(useDynamicColor);setState(() {});},- title: Text('动态配色', style: TextStyle(fontFamily: fontFamily)),+ title: Text('动态配色'),initialValue: useDynamicColor,),SettingsTile.switchTile(@@ -345,15 +339,12 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {setTheme(color);setState(() {});},- title:- Text('使用系统字体', style: TextStyle(fontFamily: fontFamily)),- description: Text('关闭后使用 MI Sans 字体',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('使用系统字体'),+ description: Text('关闭后使用 MI Sans 字体'),initialValue: useSystemFont,),],- bottomInfo: Text('动态配色仅支持安卓12及以上和桌面平台',- style: TextStyle(fontFamily: fontFamily)),+ bottomInfo: Text('动态配色仅支持安卓12及以上和桌面平台'),),SettingsSection(tiles: [@@ -365,10 +356,8 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {updateOledEnhance();setState(() {});},- title:- Text('OLED优化', style: TextStyle(fontFamily: fontFamily)),- description: Text('深色模式下使用纯黑背景',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('OLED优化'),+ description: Text('深色模式下使用纯黑背景'),initialValue: oledEnhance,),],@@ -383,10 +372,8 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {SettingsKeys.showWindowButton, showWindowButton);setState(() {});},- title: Text('使用系统标题栏',- style: TextStyle(fontFamily: fontFamily)),- description: Text('重启应用生效',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('使用系统标题栏'),+ description: Text('重启应用生效'),initialValue: showWindowButton,),],@@ -394,12 +381,11 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {if (Platform.isAndroid)SettingsSection(tiles: [- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {context.pushNamed('/settings/theme/display');},- title:- Text('屏幕帧率', style: TextStyle(fontFamily: fontFamily)),+ title: Text('屏幕帧率'),),],),diff --git a/lib/pages/webdav_editor/webdav_setting.dart b/lib/pages/webdav_editor/webdav_setting.dartindex dc233ee7..2b3d208a 100644--- a/lib/pages/webdav_editor/webdav_setting.dart+++ b/lib/pages/webdav_editor/webdav_setting.dart@@ -5,8 +5,8 @@ import 'package:kazumi/services/logging/logger.dart';import 'package:kazumi/services/storage/storage.dart';import 'package:kazumi/services/sync/webdav.dart';import 'package:flutter_modular/flutter_modular.dart';-import 'package:kazumi/bean/appbar/sys_app_bar.dart';-import 'package:card_settings_ui/card_settings_ui.dart';+import 'package:kazumi/bean/settings/settings_detail_scaffold.dart';+import 'package:kazumi/bean/settings/settings_list.dart';class WebDavSettingsPage extends StatefulWidget {const WebDavSettingsPage({super.key});@@ -70,19 +70,18 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {@overrideWidget build(BuildContext context) {- final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;return PopScope(canPop: true,onPopInvokedWithResult: (bool didPop, Object? result) {onBackPressed(context);},- child: Scaffold(- appBar: const SysAppBar(title: Text('同步设置')),+ child: SettingsDetailScaffold(+ title: const Text('同步设置'),body: SettingsList(maxWidth: 1000,sections: [SettingsSection(- title: Text('规则仓库', style: TextStyle(fontFamily: fontFamily)),+ title: Text('规则仓库'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -91,16 +90,14 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {SettingsKeys.enableGitProxy, enableGitProxy);setState(() {});},- title:- Text('规则仓库镜像', style: TextStyle(fontFamily: fontFamily)),- description: Text('使用镜像访问规则更新和管理仓库',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('规则仓库镜像'),+ description: Text('使用镜像访问规则更新和管理仓库'),initialValue: enableGitProxy,),],),SettingsSection(- title: Text('Bangumi', style: TextStyle(fontFamily: fontFamily)),+ title: Text('Bangumi'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -111,10 +108,8 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {setState(() {});}},- title: Text('Bangumi 镜像',- style: TextStyle(fontFamily: fontFamily)),- description: Text('使用本地 Bangumi 缓存后端加载热门与分类榜单',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('Bangumi 镜像'),+ description: Text('使用本地 Bangumi 缓存后端加载热门与分类榜单'),initialValue: enableBangumiProxy,),SettingsTile.switchTile(@@ -149,26 +144,23 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {}setState(() {});},- title: Text('Bangumi 同步',- style: TextStyle(fontFamily: fontFamily)),- description: Text('允许与Bangumi自动同步收藏/追番状态',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('Bangumi 同步'),+ description: Text('允许与Bangumi自动同步收藏/追番状态'),initialValue: bangumiSyncEnable,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {await context.pushNamed('/settings/bangumi/');bangumiSyncEnable =GStorage.getSetting(SettingsKeys.bangumiSyncEnable);setState(() {});},- title: Text('Bangumi 配置',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('Bangumi 配置'),),],),SettingsSection(- title: Text('WEBDAV', style: TextStyle(fontFamily: fontFamily)),+ title: Text('WEBDAV'),tiles: [SettingsTile.switchTile(onToggle: (value) async {@@ -195,8 +187,7 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {setState(() {});}},- title: Text('WEBDAV同步',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('WEBDAV同步'),initialValue: webDavEnable,),SettingsTile.switchTile(@@ -210,10 +201,8 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {SettingsKeys.webDavEnableHistory, webDavEnableHistory);setState(() {});},- title:- Text('观看记录同步', style: TextStyle(fontFamily: fontFamily)),- description: Text('允许自动同步观看记录',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('观看记录同步'),+ description: Text('允许自动同步观看记录'),initialValue: webDavEnableHistory,),SettingsTile.switchTile(@@ -227,27 +216,23 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {SettingsKeys.webDavEnableCollect, webDavEnableCollect);setState(() {});},- title: Text('收藏同步', style: TextStyle(fontFamily: fontFamily)),- description: Text('允许 WebDAV 参与追番状态同步',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('收藏同步'),+ description: Text('允许 WebDAV 参与追番状态同步'),initialValue: webDavEnableCollect,),- SettingsTile.navigation(+ SettingsTile(onPressed: (_) async {context.pushNamed('/settings/webdav/editor');},- title: Text('WEBDAV配置',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('WEBDAV配置'),),SettingsTile(trailing: const Icon(Icons.sync_rounded),onPressed: (_) {syncHistoryWithWebDav();},- title: Text('立即同步观看记录',- style: TextStyle(fontFamily: fontFamily)),- description: Text('与WEBDAV双向合并观看记录',- style: TextStyle(fontFamily: fontFamily)),+ title: Text('立即同步观看记录'),+ description: Text('与WEBDAV双向合并观看记录'),),],),diff --git a/lib/repositories/collect_crud_repository.dart b/lib/repositories/collect_crud_repository.dartindex ac78f6fb..a869570d 100644--- a/lib/repositories/collect_crud_repository.dart+++ b/lib/repositories/collect_crud_repository.dart@@ -8,6 +8,9 @@ import 'package:kazumi/services/logging/logger.dart';////// 提供收藏数据的增删改查操作abstract class ICollectCrudRepository {+ /// Emits once per collectible write, WebDAV sync restores included.+ Stream<void> get changes;+/// 获取所有收藏List<CollectedBangumi> getAllCollectibles();@@ -58,6 +61,9 @@ class CollectCrudRepository implements ICollectCrudRepository {final _collectiblesBox = GStorage.collectibles;final _favoritesBox = GStorage.favorites;+ @override+ Stream<void> get changes => _collectiblesBox.watch();+@overrideList<CollectedBangumi> getAllCollectibles() {try {diff --git a/lib/repositories/download_repository.dart b/lib/repositories/download_repository.dartindex c1117ec1..f29fc837 100644--- a/lib/repositories/download_repository.dart+++ b/lib/repositories/download_repository.dart@@ -3,6 +3,10 @@ import 'package:kazumi/modules/download/download_module.dart';import 'package:kazumi/services/logging/logger.dart';abstract class IDownloadRepository {+ /// Emits when a record or an episode status is persisted. Progress ticks stay+ /// in memory, so they do not emit.+ Stream<void> get changes;+List<DownloadRecord> getAllRecords();DownloadRecord? getRecord(String key);Future<void> putRecord(DownloadRecord record);@@ -46,6 +50,9 @@ abstract class IDownloadRepository {class DownloadRepository implements IDownloadRepository {final _downloadsBox = GStorage.downloads;+ @override+ Stream<void> get changes => _downloadsBox.watch();+@overrideList<DownloadRecord> getAllRecords() {final List<DownloadRecord> result = [];diff --git a/lib/repositories/history_repository.dart b/lib/repositories/history_repository.dartindex e9abc281..06eaa260 100644--- a/lib/repositories/history_repository.dart+++ b/lib/repositories/history_repository.dart@@ -23,6 +23,11 @@ typedef HistoryClearSyncAppender = Future<void> Function();////// 提供观看历史相关的数据访问抽象abstract class IHistoryRepository {+ /// 历史记录变更事件流+ ///+ /// 写入、删除、清空各推送一次。所有历史写入都经过本仓库。+ Stream<void> get changes;+/// 获取所有历史记录(按时间倒序)List<History> getAllHistories();@@ -143,6 +148,9 @@ class HistoryRepository implements IHistoryRepository {);}+ @override+ Stream<void> get changes => _historiesBox.watch();+@overrideList<History> getAllHistories() {try {diff --git a/lib/services/player/history_playback_service.dart b/lib/services/player/history_playback_service.dartnew file mode 100644index 00000000..bda633fe--- /dev/null+++ b/lib/services/player/history_playback_service.dart@@ -0,0 +1,141 @@+import 'package:kazumi/modules/download/download_module.dart';+import 'package:kazumi/modules/history/history_module.dart';+import 'package:kazumi/pages/download/download_controller.dart';+import 'package:kazumi/pages/video/video_playback_args.dart';+import 'package:kazumi/plugins/plugins.dart';+import 'package:kazumi/plugins/plugins_controller.dart';+import 'package:kazumi/services/logging/logger.dart';+import 'package:kazumi/services/plugin/rule_engine_models.dart'+ show RuleCancelToken;++sealed class HistoryPlaybackResult {+ const HistoryPlaybackResult();+}++class HistoryPlaybackReady extends HistoryPlaybackResult {+ const HistoryPlaybackReady(this.args);++ final VideoPlaybackArgs args;+}++class HistoryPlaybackUnavailable extends HistoryPlaybackResult {+ const HistoryPlaybackUnavailable(this.reason);++ final String reason;+}++/// Restores a history entry into arguments the player route can take.+///+/// The history page and the my page share this one resolution path; cards+/// carry no source-lookup logic of their own.+class HistoryPlaybackService {+ HistoryPlaybackService(this._pluginsController, this._downloadController);++ final PluginsController _pluginsController;+ final DownloadController _downloadController;++ /// [cancelToken] lets the caller abort the online lookup, e.g. when the+ /// loading dialog it put up is dismissed.+ Future<HistoryPlaybackResult> open(+ History history, {+ RuleCancelToken? cancelToken,+ }) async {+ if (HistoryEntryKind.normalize(history.entryKind) ==+ HistoryEntryKind.offline) {+ final args = _offlineArgs(history);+ return args == null+ ? const HistoryPlaybackUnavailable('未找到可用缓存')+ : HistoryPlaybackReady(args);+ }++ final args = await _onlineArgs(history, cancelToken);+ return args == null+ ? const HistoryPlaybackUnavailable('在线源不可用,请重新选择播放源')+ : HistoryPlaybackReady(args);+ }++ Future<VideoPlaybackArgs?> _onlineArgs(+ History history,+ RuleCancelToken? cancelToken,+ ) async {+ if (history.lastSrc.isEmpty) {+ return null;+ }+ Plugin? targetPlugin;+ for (final plugin in _pluginsController.pluginList) {+ if (plugin.name == history.adapterName) {+ targetPlugin = plugin;+ break;+ }+ }+ if (targetPlugin == null) {+ return null;+ }+ try {+ final roads = await targetPlugin.queryChapterRoads(+ history.lastSrc,+ cancelToken: cancelToken,+ );+ if (roads.isEmpty) {+ return null;+ }+ return OnlineVideoPlaybackArgs(+ bangumiItem: history.bangumiItem,+ plugin: targetPlugin,+ title: history.bangumiItem.nameCn.isEmpty+ ? history.bangumiItem.name+ : history.bangumiItem.nameCn,+ src: history.lastSrc,+ roads: roads,+ );+ } catch (_) {+ KazumiLogger().w("QueryManager: failed to query roads");+ return null;+ }+ }++ VideoPlaybackArgs? _offlineArgs(History history) {+ final downloadedEpisodes = _downloadController.getCompletedEpisodes(+ history.bangumiItem.id,+ history.adapterName,+ );+ if (downloadedEpisodes.isEmpty) {+ return null;+ }++ // The page url pins the exact episode; the number is the legacy fallback.+ DownloadEpisode? targetEpisode;+ DownloadEpisode? numberMatch;+ for (final episode in downloadedEpisodes) {+ if (history.episodePageUrl.isNotEmpty &&+ episode.episodePageUrl == history.episodePageUrl) {+ targetEpisode = episode;+ break;+ }+ if (episode.episodeNumber == history.lastWatchEpisode) {+ numberMatch ??= episode;+ }+ }+ targetEpisode ??= numberMatch;+ if (targetEpisode == null) {+ return null;+ }++ final localPath = _downloadController.getLocalVideoPath(+ history.bangumiItem.id,+ history.adapterName,+ targetEpisode.episodeNumber,+ );+ if (localPath == null) {+ return null;+ }++ return OfflineVideoPlaybackArgs(+ bangumiItem: history.bangumiItem,+ pluginName: history.adapterName,+ episodeNumber: targetEpisode.episodeNumber,+ road: targetEpisode.road,+ downloadedEpisodes: downloadedEpisodes,+ );+ }+}diff --git a/pubspec.lock b/pubspec.lockindex c18e45fa..4a23c9ee 100644--- a/pubspec.lock+++ b/pubspec.lock@@ -211,14 +211,6 @@ packages:url: "https://pub.dev"source: hostedversion: "0.3.1"- card_settings_ui:- dependency: "direct main"- description:- name: card_settings_ui- sha256: "73670e4685d44fed8e9669e813153801825eea6f7a2845665e3a5a8631761e6c"- url: "https://pub.dev"- source: hosted- version: "2.0.1"characters:dependency: transitivedescription:diff --git a/pubspec.yaml b/pubspec.yamlindex ed0b02e8..5461e6e5 100644--- a/pubspec.yaml+++ b/pubspec.yaml@@ -52,7 +52,6 @@ dependencies:flutter_cache_manager: ^3.4.1image: ^4.8.0# cached_network_image_ce: ^4.6.4- card_settings_ui: ^2.0.1file_picker: ^10.3.7# fvp: ^0.28.0