[mob][photos] Update select all button's state checking if all are selected or not on each select/unselect operation

This commit is contained in:
ashilkn
2024-06-15 12:21:58 +05:30
parent f04e54f68b
commit 1b993a617a

View File

@@ -112,14 +112,14 @@ class _SelectAllButtonState extends State<SelectAllButton> {
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<SelectAllButton> {
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,
);
},
),
],
),