基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
feat(player): add select all toggle to screenshot review sheet (#2629)
rinnki290d0be02951
diff --git a/lib/pages/player/controller/player_screenshot_controller.dart b/lib/pages/player/controller/player_screenshot_controller.dartindex 8b3e61ef..c2042092 100644--- a/lib/pages/player/controller/player_screenshot_controller.dart+++ b/lib/pages/player/controller/player_screenshot_controller.dart@@ -48,6 +48,11 @@ abstract class _PlayerScreenshotController with Store {@computedint get selectedCount => _selected.length;+ // Selection only ever holds ids of current candidates.+ @computed+ bool get allSelected =>+ _candidates.isNotEmpty && _selected.length == _candidates.length;+bool isSelected(ScreenshotCandidate item) => _selected.contains(item.id);void _report(String message, {bool error = false}) {@@ -114,6 +119,16 @@ abstract class _PlayerScreenshotController with Store {if (!_selected.remove(item.id)) _selected.add(item.id);}+ @action+ void setAllSelected(bool selected) {+ if (_disposed || _saving) return;+ if (selected) {+ _selected.addAll(_candidates.map((item) => item.id));+ } else {+ _selected.clear();+ }+ }+void _removeCandidates(Iterable<ScreenshotCandidate> items) {final removed = items.toList();if (removed.isEmpty) return;diff --git a/lib/pages/player/controller/player_screenshot_controller.g.dart b/lib/pages/player/controller/player_screenshot_controller.g.dartindex 1437348c..b22def14 100644--- a/lib/pages/player/controller/player_screenshot_controller.g.dart+++ b/lib/pages/player/controller/player_screenshot_controller.g.dart@@ -23,6 +23,13 @@ mixin _$PlayerScreenshotController on _PlayerScreenshotController, Store {() => super.selectedCount,name: '_PlayerScreenshotController.selectedCount',)).value;+ Computed<bool>? _$allSelectedComputed;++ @override+ bool get allSelected => (_$allSelectedComputed ??= Computed<bool>(+ () => super.allSelected,+ name: '_PlayerScreenshotController.allSelected',+ )).value;late final _$_capturingAtom = Atom(name: '_PlayerScreenshotController._capturing',@@ -199,6 +206,17 @@ mixin _$PlayerScreenshotController on _PlayerScreenshotController, Store {}}+ @override+ void setAllSelected(bool selected) {+ final _$actionInfo = _$_PlayerScreenshotControllerActionController+ .startAction(name: '_PlayerScreenshotController.setAllSelected');+ try {+ return super.setAllSelected(selected);+ } finally {+ _$_PlayerScreenshotControllerActionController.endAction(_$actionInfo);+ }+ }+@overridevoid removeSelected() {final _$actionInfo = _$_PlayerScreenshotControllerActionController@@ -236,7 +254,8 @@ mixin _$PlayerScreenshotController on _PlayerScreenshotController, Store {String toString() {return '''busy: ${busy},-selectedCount: ${selectedCount}+selectedCount: ${selectedCount},+allSelected: ${allSelected}''';}}diff --git a/lib/pages/player/player_screenshot_sheet.dart b/lib/pages/player/player_screenshot_sheet.dartindex f9a9ec9a..060dde89 100644--- a/lib/pages/player/player_screenshot_sheet.dart+++ b/lib/pages/player/player_screenshot_sheet.dart@@ -620,13 +620,7 @@ class _PlayerScreenshotSheetState extends State<_PlayerScreenshotSheet> {return Semantics(selected: selected,child: FilledButton.tonalIcon(- style: _actionStyle(selected: selected).copyWith(- backgroundColor: WidgetStatePropertyAll(- selected- ? Theme.of(context).colorScheme.secondaryContainer- : Theme.of(context).colorScheme.surfaceContainerHighest,- ),- ),+ style: _toggleStyle(selected: selected),onPressed: collection.saving ? null : _toggle,icon: Icon(selected@@ -734,23 +728,45 @@ class _PlayerScreenshotSheetState extends State<_PlayerScreenshotSheet> {),child: LayoutBuilder(builder: (context, constraints) {- final stacked =- stackActions ||- constraints.maxWidth < saveWidth + scaler.scale(96) + 48;+ // Rough width the single-row layout needs before it must stack.+ final rowWidth =+ saveWidth ++ scaler.scale(96) ++ scaler.scale(128) ++ (showReturn ? scaler.scale(56) + 32 : 0) ++ 56;+ final stacked = stackActions || constraints.maxWidth < rowWidth;final pick = SizedBox(height: buttonHeight,child: _pickButton(current!),);+ final selectAll = _selectAllButton(+ height: buttonHeight,+ compact: stacked,+ );if (stacked) {return Column(crossAxisAlignment: CrossAxisAlignment.stretch,- children: [pick, const SizedBox(height: 8), save],+ children: [+ // Select-all stays intrinsic so the pick label never truncates.+ Row(+ children: [+ Expanded(child: pick),+ const SizedBox(width: 8),+ selectAll,+ ],+ ),+ const SizedBox(height: 8),+ save,+ ],);}return Row(children: [pick,const Spacer(),+ selectAll,+ const SizedBox(width: 8),if (showReturn) ...[Observer(builder: (context) => TextButton(@@ -768,6 +784,50 @@ class _PlayerScreenshotSheetState extends State<_PlayerScreenshotSheet> {);}+ Widget _selectAllButton({required double height, required bool compact}) =>+ SizedBox(+ height: height,+ child: Observer(+ builder: (context) {+ final all = collection.allSelected;+ final style = _toggleStyle(selected: all);+ final onPressed = collection.saving+ ? null+ : () => collection.setAllSelected(!all);+ final label = Text(all ? '取消全选' : '全选');+ if (compact) {+ return FilledButton.tonal(+ style: style.copyWith(+ padding: const WidgetStatePropertyAll(+ EdgeInsets.symmetric(horizontal: 8, vertical: 12),+ ),+ ),+ onPressed: onPressed,+ child: label,+ );+ }+ return FilledButton.tonalIcon(+ style: style,+ onPressed: onPressed,+ icon: Icon(+ all ? Icons.deselect_rounded : Icons.select_all_rounded,+ size: 20,+ ),+ label: label,+ );+ },+ ),+ );++ ButtonStyle _toggleStyle({required bool selected}) {+ final colors = Theme.of(context).colorScheme;+ return _actionStyle(selected: selected).copyWith(+ backgroundColor: WidgetStatePropertyAll(+ selected ? colors.secondaryContainer : colors.surfaceContainerHighest,+ ),+ );+ }+ButtonStyle _actionStyle({bool selected = false}) => ButtonStyle(minimumSize: const WidgetStatePropertyAll(Size(48, 48)),padding: const WidgetStatePropertyAll(