From d10748a67beefcc4d16e80d5bb146d52995e5143 Mon Sep 17 00:00:00 2001 From: csf Date: Wed, 19 Oct 2022 11:49:32 +0900 Subject: [PATCH] mobile file transfer handle driver & update UI theme --- .../lib/mobile/pages/file_manager_page.dart | 141 ++++++++++-------- flutter/lib/models/file_model.dart | 1 + 2 files changed, 78 insertions(+), 64 deletions(-) diff --git a/flutter/lib/mobile/pages/file_manager_page.dart b/flutter/lib/mobile/pages/file_manager_page.dart index 0ee0e0f8d..0ff6c83da 100644 --- a/flutter/lib/mobile/pages/file_manager_page.dart +++ b/flutter/lib/mobile/pages/file_manager_page.dart @@ -69,8 +69,14 @@ class _FileManagerPageState extends State { title: ToggleSwitch( initialLabelIndex: model.isLocal ? 0 : 1, activeBgColor: [MyTheme.idColor], - // inactiveBgColor: MyTheme.grayBg, - inactiveFgColor: Colors.black54, + inactiveBgColor: + Theme.of(context).brightness == Brightness.light + ? MyTheme.grayBg + : null, + inactiveFgColor: + Theme.of(context).brightness == Brightness.light + ? Colors.black54 + : null, totalSwitches: 2, minWidth: 100, fontSize: 15, @@ -92,7 +98,8 @@ class _FileManagerPageState extends State { PopupMenuItem( child: Row( children: [ - Icon(Icons.refresh, color: Colors.black), + Icon(Icons.refresh, + color: Theme.of(context).iconTheme.color), SizedBox(width: 5), Text(translate("Refresh File")) ], @@ -102,7 +109,8 @@ class _FileManagerPageState extends State { PopupMenuItem( child: Row( children: [ - Icon(Icons.check, color: Colors.black), + Icon(Icons.check, + color: Theme.of(context).iconTheme.color), SizedBox(width: 5), Text(translate("Multi Select")) ], @@ -113,7 +121,7 @@ class _FileManagerPageState extends State { child: Row( children: [ Icon(Icons.folder_outlined, - color: Colors.black), + color: Theme.of(context).iconTheme.color), SizedBox(width: 5), Text(translate("Create Folder")) ], @@ -127,7 +135,7 @@ class _FileManagerPageState extends State { model.currentShowHidden ? Icons.check_box_outlined : Icons.check_box_outline_blank, - color: Colors.black), + color: Theme.of(context).iconTheme.color), SizedBox(width: 5), Text(translate("Show Hidden Files")) ], @@ -188,7 +196,7 @@ class _FileManagerPageState extends State { )); })); - bool needShowCheckBox() { + bool showCheckBox() { if (!model.selectMode) { return false; } @@ -220,60 +228,63 @@ class _FileManagerPageState extends State { return Card( child: ListTile( leading: Icon( - entries[index].isFile ? Icons.feed_outlined : Icons.folder, + entries[index].isFile + ? Icons.feed_outlined + : entries[index].isDrive + ? Icons.computer + : Icons.folder, size: 40), title: Text(entries[index].name), selected: selected, subtitle: Text( - entries[index] - .lastModified() - .toString() - .replaceAll(".000", "") + - " " + - sizeStr, + entries[index].isDrive + ? "" + : "${entries[index].lastModified().toString().replaceAll(".000", "")} $sizeStr", style: TextStyle(fontSize: 12, color: MyTheme.darkGray), ), - trailing: needShowCheckBox() - ? Checkbox( - value: selected, - onChanged: (v) { - if (v == null) return; - if (v && !selected) { - _selectedItems.add(isLocal, entries[index]); - } else if (!v && selected) { - _selectedItems.remove(entries[index]); - } - setState(() {}); - }) - : PopupMenuButton( - icon: Icon(Icons.more_vert), - itemBuilder: (context) { - return [ - PopupMenuItem( - child: Text(translate("Delete")), - value: "delete", - ), - PopupMenuItem( - child: Text(translate("Multi Select")), - value: "multi_select", - ), - PopupMenuItem( - child: Text(translate("Properties")), - value: "properties", - enabled: false, - ) - ]; - }, - onSelected: (v) { - if (v == "delete") { - final items = SelectedItems(); - items.add(isLocal, entries[index]); - model.removeAction(items); - } else if (v == "multi_select") { - _selectedItems.clear(); - model.toggleSelectMode(); - } - }), + trailing: entries[index].isDrive + ? null + : showCheckBox() + ? Checkbox( + value: selected, + onChanged: (v) { + if (v == null) return; + if (v && !selected) { + _selectedItems.add(isLocal, entries[index]); + } else if (!v && selected) { + _selectedItems.remove(entries[index]); + } + setState(() {}); + }) + : PopupMenuButton( + icon: Icon(Icons.more_vert), + itemBuilder: (context) { + return [ + PopupMenuItem( + child: Text(translate("Delete")), + value: "delete", + ), + PopupMenuItem( + child: Text(translate("Multi Select")), + value: "multi_select", + ), + PopupMenuItem( + child: Text(translate("Properties")), + value: "properties", + enabled: false, + ) + ]; + }, + onSelected: (v) { + if (v == "delete") { + final items = SelectedItems(); + items.add(isLocal, entries[index]); + model.removeAction(items); + } else if (v == "multi_select") { + _selectedItems.clear(); + model.toggleSelectMode(); + } + }), onTap: () { if (model.selectMode && !_selectedItems.isOtherPage(isLocal)) { if (selected) { @@ -284,21 +295,23 @@ class _FileManagerPageState extends State { setState(() {}); return; } - if (entries[index].isDirectory) { + if (entries[index].isDirectory || entries[index].isDrive) { model.openDirectory(entries[index].path); breadCrumbScrollToEnd(); } else { // Perform file-related tasks. } }, - onLongPress: () { - _selectedItems.clear(); - model.toggleSelectMode(); - if (model.selectMode) { - _selectedItems.add(isLocal, entries[index]); - } - setState(() {}); - }, + onLongPress: entries[index].isDrive + ? null + : () { + _selectedItems.clear(); + model.toggleSelectMode(); + if (model.selectMode) { + _selectedItems.add(isLocal, entries[index]); + } + setState(() {}); + }, ), ); }, diff --git a/flutter/lib/models/file_model.dart b/flutter/lib/models/file_model.dart index c7d712eb5..1ea9f65a1 100644 --- a/flutter/lib/models/file_model.dart +++ b/flutter/lib/models/file_model.dart @@ -1139,6 +1139,7 @@ class SelectedItems { bool? get isLocal => _isLocal; add(bool isLocal, Entry e) { + if (e.isDrive) return; _isLocal ??= isLocal; if (_isLocal != null && _isLocal != isLocal) { return;