mobile file transfer handle driver & update UI theme

This commit is contained in:
csf 2022-10-19 11:49:32 +09:00
parent ec698e6885
commit d10748a67b
2 changed files with 78 additions and 64 deletions
flutter/lib

@ -69,8 +69,14 @@ class _FileManagerPageState extends State<FileManagerPage> {
title: ToggleSwitch( title: ToggleSwitch(
initialLabelIndex: model.isLocal ? 0 : 1, initialLabelIndex: model.isLocal ? 0 : 1,
activeBgColor: [MyTheme.idColor], activeBgColor: [MyTheme.idColor],
// inactiveBgColor: MyTheme.grayBg, inactiveBgColor:
inactiveFgColor: Colors.black54, Theme.of(context).brightness == Brightness.light
? MyTheme.grayBg
: null,
inactiveFgColor:
Theme.of(context).brightness == Brightness.light
? Colors.black54
: null,
totalSwitches: 2, totalSwitches: 2,
minWidth: 100, minWidth: 100,
fontSize: 15, fontSize: 15,
@ -92,7 +98,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
PopupMenuItem( PopupMenuItem(
child: Row( child: Row(
children: [ children: [
Icon(Icons.refresh, color: Colors.black), Icon(Icons.refresh,
color: Theme.of(context).iconTheme.color),
SizedBox(width: 5), SizedBox(width: 5),
Text(translate("Refresh File")) Text(translate("Refresh File"))
], ],
@ -102,7 +109,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
PopupMenuItem( PopupMenuItem(
child: Row( child: Row(
children: [ children: [
Icon(Icons.check, color: Colors.black), Icon(Icons.check,
color: Theme.of(context).iconTheme.color),
SizedBox(width: 5), SizedBox(width: 5),
Text(translate("Multi Select")) Text(translate("Multi Select"))
], ],
@ -113,7 +121,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
child: Row( child: Row(
children: [ children: [
Icon(Icons.folder_outlined, Icon(Icons.folder_outlined,
color: Colors.black), color: Theme.of(context).iconTheme.color),
SizedBox(width: 5), SizedBox(width: 5),
Text(translate("Create Folder")) Text(translate("Create Folder"))
], ],
@ -127,7 +135,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
model.currentShowHidden model.currentShowHidden
? Icons.check_box_outlined ? Icons.check_box_outlined
: Icons.check_box_outline_blank, : Icons.check_box_outline_blank,
color: Colors.black), color: Theme.of(context).iconTheme.color),
SizedBox(width: 5), SizedBox(width: 5),
Text(translate("Show Hidden Files")) Text(translate("Show Hidden Files"))
], ],
@ -188,7 +196,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
)); ));
})); }));
bool needShowCheckBox() { bool showCheckBox() {
if (!model.selectMode) { if (!model.selectMode) {
return false; return false;
} }
@ -220,60 +228,63 @@ class _FileManagerPageState extends State<FileManagerPage> {
return Card( return Card(
child: ListTile( child: ListTile(
leading: Icon( 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), size: 40),
title: Text(entries[index].name), title: Text(entries[index].name),
selected: selected, selected: selected,
subtitle: Text( subtitle: Text(
entries[index] entries[index].isDrive
.lastModified() ? ""
.toString() : "${entries[index].lastModified().toString().replaceAll(".000", "")} $sizeStr",
.replaceAll(".000", "") +
" " +
sizeStr,
style: TextStyle(fontSize: 12, color: MyTheme.darkGray), style: TextStyle(fontSize: 12, color: MyTheme.darkGray),
), ),
trailing: needShowCheckBox() trailing: entries[index].isDrive
? Checkbox( ? null
value: selected, : showCheckBox()
onChanged: (v) { ? Checkbox(
if (v == null) return; value: selected,
if (v && !selected) { onChanged: (v) {
_selectedItems.add(isLocal, entries[index]); if (v == null) return;
} else if (!v && selected) { if (v && !selected) {
_selectedItems.remove(entries[index]); _selectedItems.add(isLocal, entries[index]);
} } else if (!v && selected) {
setState(() {}); _selectedItems.remove(entries[index]);
}) }
: PopupMenuButton<String>( setState(() {});
icon: Icon(Icons.more_vert), })
itemBuilder: (context) { : PopupMenuButton<String>(
return [ icon: Icon(Icons.more_vert),
PopupMenuItem( itemBuilder: (context) {
child: Text(translate("Delete")), return [
value: "delete", PopupMenuItem(
), child: Text(translate("Delete")),
PopupMenuItem( value: "delete",
child: Text(translate("Multi Select")), ),
value: "multi_select", PopupMenuItem(
), child: Text(translate("Multi Select")),
PopupMenuItem( value: "multi_select",
child: Text(translate("Properties")), ),
value: "properties", PopupMenuItem(
enabled: false, child: Text(translate("Properties")),
) value: "properties",
]; enabled: false,
}, )
onSelected: (v) { ];
if (v == "delete") { },
final items = SelectedItems(); onSelected: (v) {
items.add(isLocal, entries[index]); if (v == "delete") {
model.removeAction(items); final items = SelectedItems();
} else if (v == "multi_select") { items.add(isLocal, entries[index]);
_selectedItems.clear(); model.removeAction(items);
model.toggleSelectMode(); } else if (v == "multi_select") {
} _selectedItems.clear();
}), model.toggleSelectMode();
}
}),
onTap: () { onTap: () {
if (model.selectMode && !_selectedItems.isOtherPage(isLocal)) { if (model.selectMode && !_selectedItems.isOtherPage(isLocal)) {
if (selected) { if (selected) {
@ -284,21 +295,23 @@ class _FileManagerPageState extends State<FileManagerPage> {
setState(() {}); setState(() {});
return; return;
} }
if (entries[index].isDirectory) { if (entries[index].isDirectory || entries[index].isDrive) {
model.openDirectory(entries[index].path); model.openDirectory(entries[index].path);
breadCrumbScrollToEnd(); breadCrumbScrollToEnd();
} else { } else {
// Perform file-related tasks. // Perform file-related tasks.
} }
}, },
onLongPress: () { onLongPress: entries[index].isDrive
_selectedItems.clear(); ? null
model.toggleSelectMode(); : () {
if (model.selectMode) { _selectedItems.clear();
_selectedItems.add(isLocal, entries[index]); model.toggleSelectMode();
} if (model.selectMode) {
setState(() {}); _selectedItems.add(isLocal, entries[index]);
}, }
setState(() {});
},
), ),
); );
}, },

@ -1139,6 +1139,7 @@ class SelectedItems {
bool? get isLocal => _isLocal; bool? get isLocal => _isLocal;
add(bool isLocal, Entry e) { add(bool isLocal, Entry e) {
if (e.isDrive) return;
_isLocal ??= isLocal; _isLocal ??= isLocal;
if (_isLocal != null && _isLocal != isLocal) { if (_isLocal != null && _isLocal != isLocal) {
return; return;