Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refactor

ashilkne01826217d7e
diff --git a/mobile/lib/ui/collections/album/vertical_list.dart b/mobile/lib/ui/collections/album/vertical_list.dart
index 3fd45fe526..321b62e9b9 100644
--- a/mobile/lib/ui/collections/album/vertical_list.dart
+++ b/mobile/lib/ui/collections/album/vertical_list.dart
@@ -34,7 +34,8 @@ class AlbumVerticalListWidget extends StatefulWidget {
final String searchQuery;
final bool shouldShowCreateAlbum;
final bool enableSelection;
- final Function(List<Collection>)? onSelectionChanged;
+ final List<Collection> selectedCollections;
+ final Function()? onSelectionChanged;
const AlbumVerticalListWidget(
this.collections,
@@ -43,6 +44,7 @@ class AlbumVerticalListWidget extends StatefulWidget {
this.sharedFiles,
this.searchQuery,
this.shouldShowCreateAlbum, {
+ required this.selectedCollections,
this.enableSelection = false,
this.onSelectionChanged,
super.key,
@@ -58,7 +60,6 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
final CollectionActions _collectionActions =
CollectionActions(CollectionsService.instance);
- List<Collection> selectedCollections = [];
@override
Widget build(BuildContext context) {
@@ -86,7 +87,7 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
: _albumListItemOnTap(context, item),
child: AlbumColumnItemWidget(
item,
- selectedCollections: selectedCollections,
+ selectedCollections: widget.selectedCollections,
),
);
},
@@ -101,14 +102,16 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
Future<void> _toggleCollectionSelection(
Collection collection,
) async {
- if (selectedCollections.contains(collection)) {
- selectedCollections.remove(collection);
+ if (widget.selectedCollections.contains(collection)) {
+ widget.selectedCollections.remove(collection);
} else {
- selectedCollections.isEmpty ? await HapticFeedback.vibrate() : null;
- selectedCollections.add(collection);
+ widget.selectedCollections.isEmpty
+ ? await HapticFeedback.vibrate()
+ : null;
+ widget.selectedCollections.add(collection);
}
if (widget.onSelectionChanged != null) {
- widget.onSelectionChanged!(selectedCollections);
+ widget.onSelectionChanged!();
}
setState(() {});
}
diff --git a/mobile/lib/ui/collections/collection_action_sheet.dart b/mobile/lib/ui/collections/collection_action_sheet.dart
index 6754a49c88..f056dc9732 100644
--- a/mobile/lib/ui/collections/collection_action_sheet.dart
+++ b/mobile/lib/ui/collections/collection_action_sheet.dart
@@ -122,7 +122,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
late final bool _enableSelection;
static const int okButtonSize = 80;
String _searchQuery = "";
- List<Collection> _selectedCollections = [];
+ final _selectedCollections = <Collection>[];
@override
void initState() {
@@ -305,8 +305,9 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
_searchQuery,
shouldShowCreateAlbum,
enableSelection: _enableSelection,
- onSelectionChanged: (c) {
- _updateSelectedCollections(c);
+ selectedCollections: _selectedCollections,
+ onSelectionChanged: () {
+ setState(() {});
},
),
),
@@ -320,12 +321,6 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
);
}
- void _updateSelectedCollections(List<Collection> collections) {
- setState(() {
- _selectedCollections = collections;
- });
- }
-
Future<List<Collection>> _getCollections() async {
if (_showOnlyHiddenCollections) {
final hiddenCollections = CollectionsService.instance