Skip to content

Commit

Permalink
Same functionality added to the browse page
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgiest05 committed Oct 27, 2024
1 parent bf295dd commit 56797dd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
10 changes: 7 additions & 3 deletions lib/components/home/select_all_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ class SelectAllNotesButton extends StatelessWidget {
final void Function() deselectAll;

bool get areAllFilesSelected {
return selectedFiles.length == allFiles.length;
for (String file in allFiles) {
if (!selectedFiles.contains(file)) return false;
}
return true;
}

@override
Widget build(BuildContext context) {
return IconButton(
padding: EdgeInsets.zero,
tooltip: areAllFilesSelected ? t.home.deselectAllNotes : t.home.selectAllNotes ,
tooltip:
areAllFilesSelected ? t.home.deselectAllNotes : t.home.selectAllNotes,
onPressed: () {
if (areAllFilesSelected)
deselectAll();
Expand All @@ -33,4 +37,4 @@ class SelectAllNotesButton extends StatelessWidget {
icon: Icon(areAllFilesSelected ? Icons.deselect : Icons.select_all),
);
}
}
}
24 changes: 20 additions & 4 deletions lib/pages/home/browse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:saber/components/home/move_note_button.dart';
import 'package:saber/components/home/new_note_button.dart';
import 'package:saber/components/home/no_files.dart';
import 'package:saber/components/home/rename_note_button.dart';
import 'package:saber/components/home/select_all_button.dart';
import 'package:saber/components/home/syncing_button.dart';
import 'package:saber/data/file_manager/file_manager.dart';
import 'package:saber/data/routes.dart';
Expand All @@ -31,6 +32,13 @@ class BrowsePage extends StatefulWidget {
class _BrowsePageState extends State<BrowsePage> {
DirectoryChildren? children;

List<String> get notesInCwd {
return [
for (String filePath in children?.files ?? const [])
"${path ?? ""}/$filePath",
];
}

final List<String?> pathHistory = [];
String? path;

Expand Down Expand Up @@ -185,10 +193,7 @@ class _BrowsePageState extends State<BrowsePage> {
),
sliver: MasonryFiles(
crossAxisCount: crossAxisCount,
files: [
for (String filePath in children?.files ?? const [])
"${path ?? ""}/$filePath",
],
files: notesInCwd,
selectedFiles: selectedFiles,
),
),
Expand Down Expand Up @@ -234,6 +239,17 @@ class _BrowsePageState extends State<BrowsePage> {
},
icon: const Icon(Icons.delete_forever),
),
SelectAllNotesButton(
selectedFiles: selectedFiles.value,
allFiles: notesInCwd,
selectAll: () => {
selectedFiles.value.clear(),
for (String filePath in notesInCwd)
selectedFiles.value.add(filePath),
setState(() {})
},
deselectAll: () => {selectedFiles.value = []},
),
ExportNoteButton(
selectedFiles: selectedFiles.value,
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dependencies:
defer_pointer: ^0.0.2

permission_handler: ^11.3.1
saver_gallery: 3.0.5
saver_gallery: ^4.0.0

animations: ^2.0.7

Expand Down

0 comments on commit 56797dd

Please sign in to comment.