基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
refactor(ui): share the category row across settings and my page
Prediditda330d7f5679
diff --git a/lib/bean/settings/settings_list.dart b/lib/bean/settings/settings_list.dartindex a027f2d3..fc2db5f9 100644--- a/lib/bean/settings/settings_list.dart+++ b/lib/bean/settings/settings_list.dart@@ -81,10 +81,19 @@ class SettingsSection extends StatelessWidget {/// small ones in between, and a pressed row morphing out of the group. That/// morph is what separates the rows, in place of a divider.class SettingsSplitGroup extends StatelessWidget {- const SettingsSplitGroup({super.key, required this.children});+ const SettingsSplitGroup({+ super.key,+ required this.children,+ this.outerRadius = _outerRadius,+ });final List<Widget> children;+ /// The group's two end corners, and the radius a pressed row morphs to.+ /// Settings pages take the default; a page whose surrounding cards run at a+ /// smaller scale passes theirs so the group sits level with them.+ final double outerRadius;+/// Hand to a row's [InkWell.onHighlightChanged] to drive the morph. Null/// outside a group, which leaves the row's shape static.static ValueChanged<bool>? pressReporterOf(BuildContext context) {@@ -103,6 +112,7 @@ class SettingsSplitGroup extends StatelessWidget {_SplitRow(first: i == 0,last: i == children.length - 1,+ outerRadius: outerRadius,child: children[i],),],@@ -115,11 +125,13 @@ class _SplitRow extends StatefulWidget {const _SplitRow({required this.first,required this.last,+ required this.outerRadius,required this.child,});final bool first;final bool last;+ final double outerRadius;final Widget child;@override@@ -131,8 +143,9 @@ class _SplitRowState extends State<_SplitRow> {@overrideWidget build(BuildContext context) {- final top = widget.first || _pressed ? _outerRadius : _innerRadius;- final bottom = widget.last || _pressed ? _outerRadius : _innerRadius;+ final outer = widget.outerRadius;+ final top = widget.first || _pressed ? outer : _innerRadius;+ final bottom = widget.last || _pressed ? outer : _innerRadius;return Material(// Material animates its own shape, so the morph needs no controller.color: Theme.of(context).colorScheme.surfaceContainerLow,@@ -243,6 +256,75 @@ class _TileLabel extends StatelessWidget {}}+/// A row that opens a whole category rather than changing one value: the+/// tonal icon badge marks that step down, which is why [SettingsTile] keeps a+/// flat icon. Drop it in a [SettingsSplitGroup] like any other row.+class SettingsCategoryTile extends StatelessWidget {+ const SettingsCategoryTile({+ super.key,+ required this.icon,+ required this.title,+ required this.description,+ required this.onTap,+ });++ final IconData icon;+ final String title;+ final String description;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final colorScheme = Theme.of(context).colorScheme;+ final textTheme = Theme.of(context).textTheme;+ return InkWell(+ onTap: onTap,+ onHighlightChanged: SettingsSplitGroup.pressReporterOf(context),+ 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(+ icon,+ size: 18,+ color: colorScheme.onSecondaryContainer,+ ),+ ),+ const SizedBox(width: 16),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(title, style: textTheme.bodyLarge),+ const SizedBox(height: 2),+ Text(+ description,+ style: textTheme.bodySmall+ ?.copyWith(color: colorScheme.onSurfaceVariant),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),+ ),+ Icon(+ Icons.chevron_right_rounded,+ color: colorScheme.onSurfaceVariant,+ ),+ ],+ ),+ ),+ );+ }+}+/// A row whose control is a slider. The label line carries a tonal readout of/// the current value and the track spans the row beneath it, so the icon, the/// track and the text never share a line.diff --git a/lib/pages/my/my_page.dart b/lib/pages/my/my_page.dartindex f8d65a0d..2458608e 100644--- a/lib/pages/my/my_page.dart+++ b/lib/pages/my/my_page.dart@@ -2,6 +2,7 @@ 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/bean/settings/settings_list.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';@@ -10,6 +11,10 @@ import 'package:kazumi/pages/my/recent_watch_card.dart';import 'package:kazumi/utils/constants.dart';import 'package:kazumi/utils/date_time.dart';+/// Shared by every block on this page, entry group included, so they read as+/// one set of cards.+const double _cardRadius = 16;+class MyPage extends StatefulWidget {const MyPage({super.key, required this.controller});@@ -202,47 +207,32 @@ class _MyPageState extends State<MyPage> {);}- /// 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.+ /// The same split list the settings page uses, at this page's card radius so+ /// the group sits level with the hero beside it.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,+ return SettingsSplitGroup(+ outerRadius: _cardRadius,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,- ),- ),- ],+ SettingsCategoryTile(+ icon: Icons.history_rounded,+ title: '历史记录',+ description: stats.lastWatchName != null+ ? '最近看到 ${stats.lastWatchName}'+ : '还没有观看记录',+ onTap: () => context.pushNamed('/settings/history/'),+ ),+ SettingsCategoryTile(+ icon: Icons.download_rounded,+ title: '离线下载',+ description: '缓存任务与本地文件',+ onTap: () => context.pushNamed('/settings/download/'),+ ),+ SettingsCategoryTile(+ icon: Icons.settings_rounded,+ title: '设置',+ description: '播放、弹幕、外观与规则',+ onTap: () => context.pushNamed('/settings/'),+ ),],);}@@ -274,7 +264,7 @@ class _CollectHero extends StatelessWidget {padding: const EdgeInsets.all(20),decoration: BoxDecoration(color: colorScheme.surfaceContainerLow,- borderRadius: BorderRadius.circular(16),+ borderRadius: BorderRadius.circular(_cardRadius),),child: Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -395,7 +385,7 @@ class _StatTile extends StatelessWidget {padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 16),decoration: BoxDecoration(color: colorScheme.surfaceContainerLow,- borderRadius: BorderRadius.circular(16),+ borderRadius: BorderRadius.circular(_cardRadius),),child: Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -436,85 +426,3 @@ class _StatTile extends StatelessWidget {}}-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,- ),- ),- 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,- ),- ],- ),- ),- Icon(- Icons.chevron_right_rounded,- size: 20,- color: colorScheme.onSurfaceVariant,- ),- ],- ),- ),- ),- );- }-}diff --git a/lib/pages/settings/settings_page.dart b/lib/pages/settings/settings_page.dartindex 2d2a3015..1634c354 100644--- a/lib/pages/settings/settings_page.dart+++ b/lib/pages/settings/settings_page.dart@@ -364,8 +364,10 @@ class _SettingsPageState extends State<SettingsPage> {SettingsSplitGroup(children: [for (final category in group.categories)- _CategoryTile(- category: category,+ SettingsCategoryTile(+ icon: category.icon,+ title: category.label,+ description: category.description,onTap: () => setState(() => _selected = category),),],@@ -426,61 +428,3 @@ class _RailDestination extends StatelessWidget {);}}--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,- onHighlightChanged: SettingsSplitGroup.pressReporterOf(context),- 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,- ),- ],- ),- ),- );- }-}