move selectedItems to file controller model

This commit is contained in:
csf
2023-03-09 18:05:09 +09:00
parent 970dfa3c88
commit 5ae3d33f3c
2 changed files with 38 additions and 38 deletions

View File

@@ -214,6 +214,7 @@ class FileController {
final OverlayDialogManager? dialogManager;
final DirectoryData Function() getOtherSideDirectoryData;
late final SelectedItems selectedItems = SelectedItems(isLocal: isLocal);
FileController(
{required this.isLocal,
@@ -1059,7 +1060,7 @@ class SelectedItems {
SelectedItems({required this.isLocal});
add(Entry e) {
void add(Entry e) {
if (e.isDrive) return;
if (!_items.contains(e)) {
_items.add(e);
@@ -1070,11 +1071,11 @@ class SelectedItems {
return _items.contains(e);
}
remove(Entry e) {
void remove(Entry e) {
_items.remove(e);
}
clear() {
void clear() {
_items.clear();
}
@@ -1082,6 +1083,14 @@ class SelectedItems {
_items.clear();
_items.addAll(entries);
}
bool valid() {
if (length > 0) {
// exclude DirDrive type
return items.any((item) => !item.isDrive);
}
return false;
}
}
// edited from [https://github.com/DevsOnFlutter/file_manager/blob/c1bf7f0225b15bcb86eba602c60acd5c4da90dd8/lib/file_manager.dart#L22]