From 168b47469ebe43c67370243b6de1d17cf35ab4fe Mon Sep 17 00:00:00 2001 From: csf Date: Tue, 11 Oct 2022 09:59:27 +0900 Subject: [PATCH] fix file transfer search feature, opt UI style --- .../lib/desktop/pages/file_manager_page.dart | 70 ++++++++++--------- flutter/lib/desktop/pages/server_page.dart | 2 +- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/flutter/lib/desktop/pages/file_manager_page.dart b/flutter/lib/desktop/pages/file_manager_page.dart index cc91a698f..212148c36 100644 --- a/flutter/lib/desktop/pages/file_manager_page.dart +++ b/flutter/lib/desktop/pages/file_manager_page.dart @@ -95,7 +95,7 @@ class _FileManagerPageState extends State _ffi.dialogManager.setOverlayState(Overlay.of(context)); return ChangeNotifierProvider.value( value: _ffi.fileModel, - child: Consumer(builder: (_context, _model, _child) { + child: Consumer(builder: (context, model, child) { return WillPopScope( onWillPop: () async { if (model.selectMode) { @@ -187,13 +187,9 @@ class _FileManagerPageState extends State controller: ScrollController(), child: ObxValue( (searchText) { - final filteredEntries = searchText.isEmpty + final filteredEntries = searchText.isNotEmpty ? entries.where((element) { - if (searchText.isEmpty) { - return true; - } else { - return element.name.contains(searchText.value); - } + return element.name.contains(searchText.value); }).toList(growable: false) : entries; return DataTable( @@ -273,22 +269,18 @@ class _FileManagerPageState extends State } } else { // Perform file-related tasks. - final _selectedItems = + final selectedItems = getSelectedItem(isLocal); - if (_selectedItems.contains(entry)) { - _selectedItems.remove(entry); + if (selectedItems.contains(entry)) { + selectedItems.remove(entry); } else { - _selectedItems.add(isLocal, entry); + selectedItems.add(isLocal, entry); } setState(() {}); } }), DataCell(Text( - entry - .lastModified() - .toString() - .replaceAll(".000", "") + - " ", + "${entry.lastModified().toString().replaceAll(".000", "")} ", style: TextStyle( fontSize: 12, color: MyTheme.darkGray), )), @@ -415,10 +407,11 @@ class _FileManagerPageState extends State } Widget headTools(bool isLocal) { - final _locationStatus = + final locationStatus = isLocal ? _locationStatusLocal : _locationStatusRemote; - final _locationFocus = isLocal ? _locationNodeLocal : _locationNodeRemote; - final _searchTextObs = isLocal ? _searchTextLocal : _searchTextRemote; + final locationFocus = isLocal ? _locationNodeLocal : _locationNodeRemote; + final searchTextObs = isLocal ? _searchTextLocal : _searchTextRemote; + final searchController = TextEditingController(text: searchTextObs.value); return Container( child: Column( children: [ @@ -476,13 +469,13 @@ class _FileManagerPageState extends State Expanded( child: GestureDetector( onTap: () { - _locationStatus.value = - _locationStatus.value == LocationStatus.bread + locationStatus.value = + locationStatus.value == LocationStatus.bread ? LocationStatus.textField : LocationStatus.bread; Future.delayed(Duration.zero, () { - if (_locationStatus.value == LocationStatus.textField) { - _locationFocus.requestFocus(); + if (locationStatus.value == LocationStatus.textField) { + locationFocus.requestFocus(); } }); }, @@ -493,7 +486,7 @@ class _FileManagerPageState extends State children: [ Expanded( child: Obx(() => - _locationStatus.value == LocationStatus.bread + locationStatus.value == LocationStatus.bread ? buildBread(isLocal) : buildPathLocation(isLocal))), DropdownButton( @@ -521,18 +514,28 @@ class _FileManagerPageState extends State child: ConstrainedBox( constraints: BoxConstraints(minWidth: 200), child: TextField( - controller: - TextEditingController(text: _searchTextObs.value), + textAlignVertical: TextAlignVertical.center, + controller: searchController, autofocus: true, - decoration: - InputDecoration(prefixIcon: Icon(Icons.search)), + decoration: InputDecoration( + prefixIcon: Icon(Icons.search), + suffix: IconButton( + icon: Icon(Icons.clear), + splashRadius: 20, + onPressed: () { + searchController.clear(); + searchTextObs.value = ""; + Get.back(); + }, + ), + ), onChanged: (searchText) => onSearchText(searchText, isLocal), ), )) ], splashRadius: 20, - child: const Icon(Icons.search), + icon: const Icon(Icons.search), ), IconButton( onPressed: () { @@ -690,9 +693,8 @@ class _FileManagerPageState extends State breadCrumbScrollToEnd(bool isLocal) { Future.delayed(Duration(milliseconds: 200), () { - final _breadCrumbScroller = getBreadCrumbScrollController(isLocal); - _breadCrumbScroller.animateTo( - _breadCrumbScroller.position.maxScrollExtent, + final breadCrumbScroller = getBreadCrumbScrollController(isLocal); + breadCrumbScroller.animateTo(breadCrumbScroller.position.maxScrollExtent, duration: Duration(milliseconds: 200), curve: Curves.fastLinearToSlowEaseIn); }); @@ -734,7 +736,7 @@ class _FileManagerPageState extends State return; } var items = SelectedItems(); - details.files.forEach((file) { + for (var file in details.files) { final f = File(file.path); items.add( true, @@ -743,7 +745,7 @@ class _FileManagerPageState extends State ..name = file.name ..size = FileSystemEntity.isDirectorySync(f.path) ? 0 : f.lengthSync()); - }); + } model.sendFiles(items, isRemote: false); } } diff --git a/flutter/lib/desktop/pages/server_page.dart b/flutter/lib/desktop/pages/server_page.dart index 3710b2932..e69557981 100644 --- a/flutter/lib/desktop/pages/server_page.dart +++ b/flutter/lib/desktop/pages/server_page.dart @@ -407,7 +407,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> { setState(() { client.recording = enabled; }); - }, translate('Allow reco)rding session')) + }, translate('Allow recording session')) ], )), ],