From 1b993a617a79d3a062f5ff06cc97e7a0328dc5eb Mon Sep 17 00:00:00 2001 From: ashilkn Date: Sat, 15 Jun 2024 12:21:58 +0530 Subject: [PATCH] [mob][photos] Update select all button's state checking if all are selected or not on each select/unselect operation --- .../actions/file_selection_overlay_bar.dart | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart index 53d835fce4..8f58c1f04f 100644 --- a/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart +++ b/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart @@ -112,14 +112,14 @@ class _SelectAllButtonState extends State { bool _selectAll = false; @override Widget build(BuildContext context) { + final selectionState = SelectionState.of(context); return GestureDetector( onTap: () { setState(() { - final selectionState = SelectionState.of(context); if (_selectAll) { - selectionState?.selectedFiles.clearAll(); + selectionState.selectedFiles.clearAll(); } else { - selectionState?.selectedFiles + selectionState.selectedFiles .selectAll(selectionState.allGalleryFiles!.toSet()); } _selectAll = !_selectAll; @@ -133,10 +133,22 @@ class _SelectAllButtonState extends State { mainAxisSize: MainAxisSize.min, children: [ const Text("All"), - Icon( - _selectAll ? Icons.check_circle : Icons.check_circle_outline, - color: - _selectAll ? getEnteColorScheme(context).strokeMuted : null, + ListenableBuilder( + listenable: selectionState.selectedFiles, + builder: (context, _) { + if (selectionState.selectedFiles.files.length == + selectionState.allGalleryFiles!.length) { + _selectAll = true; + } else { + _selectAll = false; + } + return Icon( + _selectAll ? Icons.check_circle : Icons.check_circle_outline, + color: _selectAll + ? getEnteColorScheme(context).strokeMuted + : null, + ); + }, ), ], ),