Skip to content

Commit 020b8af

Browse files
committed
Same functionality added to the browse page
1 parent 9b0b844 commit 020b8af

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

lib/components/home/select_all_button.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ class SelectAllNotesButton extends StatelessWidget {
1616
final void Function() deselectAll;
1717

1818
bool get areAllFilesSelected {
19-
return selectedFiles.length == allFiles.length;
19+
for (String file in allFiles) {
20+
if (!selectedFiles.contains(file)) return false;
21+
}
22+
return true;
2023
}
2124

2225
@override
2326
Widget build(BuildContext context) {
2427
return IconButton(
2528
padding: EdgeInsets.zero,
26-
tooltip: areAllFilesSelected ? t.home.deselectAllNotes : t.home.selectAllNotes ,
29+
tooltip:
30+
areAllFilesSelected ? t.home.deselectAllNotes : t.home.selectAllNotes,
2731
onPressed: () {
2832
if (areAllFilesSelected)
2933
deselectAll();
@@ -33,4 +37,4 @@ class SelectAllNotesButton extends StatelessWidget {
3337
icon: Icon(areAllFilesSelected ? Icons.deselect : Icons.select_all),
3438
);
3539
}
36-
}
40+
}

lib/pages/home/browse.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:saber/components/home/move_note_button.dart';
1010
import 'package:saber/components/home/new_note_button.dart';
1111
import 'package:saber/components/home/no_files.dart';
1212
import 'package:saber/components/home/rename_note_button.dart';
13+
import 'package:saber/components/home/select_all_button.dart';
1314
import 'package:saber/components/home/syncing_button.dart';
1415
import 'package:saber/data/file_manager/file_manager.dart';
1516
import 'package:saber/data/routes.dart';
@@ -31,6 +32,13 @@ class BrowsePage extends StatefulWidget {
3132
class _BrowsePageState extends State<BrowsePage> {
3233
DirectoryChildren? children;
3334

35+
List<String> get notesInCwd {
36+
return [
37+
for (String filePath in children?.files ?? const [])
38+
"${path ?? ""}/$filePath",
39+
];
40+
}
41+
3442
final List<String?> pathHistory = [];
3543
String? path;
3644

@@ -185,10 +193,7 @@ class _BrowsePageState extends State<BrowsePage> {
185193
),
186194
sliver: MasonryFiles(
187195
crossAxisCount: crossAxisCount,
188-
files: [
189-
for (String filePath in children?.files ?? const [])
190-
"${path ?? ""}/$filePath",
191-
],
196+
files: notesInCwd,
192197
selectedFiles: selectedFiles,
193198
),
194199
),
@@ -234,6 +239,17 @@ class _BrowsePageState extends State<BrowsePage> {
234239
},
235240
icon: const Icon(Icons.delete_forever),
236241
),
242+
SelectAllNotesButton(
243+
selectedFiles: selectedFiles.value,
244+
allFiles: notesInCwd,
245+
selectAll: () => {
246+
selectedFiles.value.clear(),
247+
for (String filePath in notesInCwd)
248+
selectedFiles.value.add(filePath),
249+
setState(() {})
250+
},
251+
deselectAll: () => {selectedFiles.value = []},
252+
),
237253
ExportNoteButton(
238254
selectedFiles: selectedFiles.value,
239255
),

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ dependencies:
8787
defer_pointer: ^0.0.2
8888

8989
permission_handler: ^11.3.1
90-
saver_gallery: 3.0.5
90+
saver_gallery: ^4.0.0
9191

9292
animations: ^2.0.7
9393

0 commit comments

Comments
 (0)