fix file transfer search feature, opt UI style

This commit is contained in:
csf 2022-10-11 09:59:27 +09:00
parent c0b230fd63
commit 168b47469e
2 changed files with 37 additions and 35 deletions

View File

@ -95,7 +95,7 @@ class _FileManagerPageState extends State<FileManagerPage>
_ffi.dialogManager.setOverlayState(Overlay.of(context)); _ffi.dialogManager.setOverlayState(Overlay.of(context));
return ChangeNotifierProvider.value( return ChangeNotifierProvider.value(
value: _ffi.fileModel, value: _ffi.fileModel,
child: Consumer<FileModel>(builder: (_context, _model, _child) { child: Consumer<FileModel>(builder: (context, model, child) {
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {
if (model.selectMode) { if (model.selectMode) {
@ -187,13 +187,9 @@ class _FileManagerPageState extends State<FileManagerPage>
controller: ScrollController(), controller: ScrollController(),
child: ObxValue<RxString>( child: ObxValue<RxString>(
(searchText) { (searchText) {
final filteredEntries = searchText.isEmpty final filteredEntries = searchText.isNotEmpty
? entries.where((element) { ? entries.where((element) {
if (searchText.isEmpty) { return element.name.contains(searchText.value);
return true;
} else {
return element.name.contains(searchText.value);
}
}).toList(growable: false) }).toList(growable: false)
: entries; : entries;
return DataTable( return DataTable(
@ -273,22 +269,18 @@ class _FileManagerPageState extends State<FileManagerPage>
} }
} else { } else {
// Perform file-related tasks. // Perform file-related tasks.
final _selectedItems = final selectedItems =
getSelectedItem(isLocal); getSelectedItem(isLocal);
if (_selectedItems.contains(entry)) { if (selectedItems.contains(entry)) {
_selectedItems.remove(entry); selectedItems.remove(entry);
} else { } else {
_selectedItems.add(isLocal, entry); selectedItems.add(isLocal, entry);
} }
setState(() {}); setState(() {});
} }
}), }),
DataCell(Text( DataCell(Text(
entry "${entry.lastModified().toString().replaceAll(".000", "")} ",
.lastModified()
.toString()
.replaceAll(".000", "") +
" ",
style: TextStyle( style: TextStyle(
fontSize: 12, color: MyTheme.darkGray), fontSize: 12, color: MyTheme.darkGray),
)), )),
@ -415,10 +407,11 @@ class _FileManagerPageState extends State<FileManagerPage>
} }
Widget headTools(bool isLocal) { Widget headTools(bool isLocal) {
final _locationStatus = final locationStatus =
isLocal ? _locationStatusLocal : _locationStatusRemote; isLocal ? _locationStatusLocal : _locationStatusRemote;
final _locationFocus = isLocal ? _locationNodeLocal : _locationNodeRemote; final locationFocus = isLocal ? _locationNodeLocal : _locationNodeRemote;
final _searchTextObs = isLocal ? _searchTextLocal : _searchTextRemote; final searchTextObs = isLocal ? _searchTextLocal : _searchTextRemote;
final searchController = TextEditingController(text: searchTextObs.value);
return Container( return Container(
child: Column( child: Column(
children: [ children: [
@ -476,13 +469,13 @@ class _FileManagerPageState extends State<FileManagerPage>
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
_locationStatus.value = locationStatus.value =
_locationStatus.value == LocationStatus.bread locationStatus.value == LocationStatus.bread
? LocationStatus.textField ? LocationStatus.textField
: LocationStatus.bread; : LocationStatus.bread;
Future.delayed(Duration.zero, () { Future.delayed(Duration.zero, () {
if (_locationStatus.value == LocationStatus.textField) { if (locationStatus.value == LocationStatus.textField) {
_locationFocus.requestFocus(); locationFocus.requestFocus();
} }
}); });
}, },
@ -493,7 +486,7 @@ class _FileManagerPageState extends State<FileManagerPage>
children: [ children: [
Expanded( Expanded(
child: Obx(() => child: Obx(() =>
_locationStatus.value == LocationStatus.bread locationStatus.value == LocationStatus.bread
? buildBread(isLocal) ? buildBread(isLocal)
: buildPathLocation(isLocal))), : buildPathLocation(isLocal))),
DropdownButton<String>( DropdownButton<String>(
@ -521,18 +514,28 @@ class _FileManagerPageState extends State<FileManagerPage>
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints(minWidth: 200), constraints: BoxConstraints(minWidth: 200),
child: TextField( child: TextField(
controller: textAlignVertical: TextAlignVertical.center,
TextEditingController(text: _searchTextObs.value), controller: searchController,
autofocus: true, autofocus: true,
decoration: decoration: InputDecoration(
InputDecoration(prefixIcon: Icon(Icons.search)), prefixIcon: Icon(Icons.search),
suffix: IconButton(
icon: Icon(Icons.clear),
splashRadius: 20,
onPressed: () {
searchController.clear();
searchTextObs.value = "";
Get.back();
},
),
),
onChanged: (searchText) => onChanged: (searchText) =>
onSearchText(searchText, isLocal), onSearchText(searchText, isLocal),
), ),
)) ))
], ],
splashRadius: 20, splashRadius: 20,
child: const Icon(Icons.search), icon: const Icon(Icons.search),
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
@ -690,9 +693,8 @@ class _FileManagerPageState extends State<FileManagerPage>
breadCrumbScrollToEnd(bool isLocal) { breadCrumbScrollToEnd(bool isLocal) {
Future.delayed(Duration(milliseconds: 200), () { Future.delayed(Duration(milliseconds: 200), () {
final _breadCrumbScroller = getBreadCrumbScrollController(isLocal); final breadCrumbScroller = getBreadCrumbScrollController(isLocal);
_breadCrumbScroller.animateTo( breadCrumbScroller.animateTo(breadCrumbScroller.position.maxScrollExtent,
_breadCrumbScroller.position.maxScrollExtent,
duration: Duration(milliseconds: 200), duration: Duration(milliseconds: 200),
curve: Curves.fastLinearToSlowEaseIn); curve: Curves.fastLinearToSlowEaseIn);
}); });
@ -734,7 +736,7 @@ class _FileManagerPageState extends State<FileManagerPage>
return; return;
} }
var items = SelectedItems(); var items = SelectedItems();
details.files.forEach((file) { for (var file in details.files) {
final f = File(file.path); final f = File(file.path);
items.add( items.add(
true, true,
@ -743,7 +745,7 @@ class _FileManagerPageState extends State<FileManagerPage>
..name = file.name ..name = file.name
..size = ..size =
FileSystemEntity.isDirectorySync(f.path) ? 0 : f.lengthSync()); FileSystemEntity.isDirectorySync(f.path) ? 0 : f.lengthSync());
}); }
model.sendFiles(items, isRemote: false); model.sendFiles(items, isRemote: false);
} }
} }

View File

@ -407,7 +407,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
setState(() { setState(() {
client.recording = enabled; client.recording = enabled;
}); });
}, translate('Allow reco)rding session')) }, translate('Allow recording session'))
], ],
)), )),
], ],