From ec698e688519f248dbf585277c7bf32148c70a0b Mon Sep 17 00:00:00 2001 From: csf Date: Wed, 19 Oct 2022 11:24:44 +0900 Subject: [PATCH] fix didn't show drives on '/' page --- .../lib/desktop/pages/file_manager_page.dart | 32 +++++++++---------- flutter/lib/models/file_model.dart | 6 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/flutter/lib/desktop/pages/file_manager_page.dart b/flutter/lib/desktop/pages/file_manager_page.dart index a225b55b0..fc7b6676e 100644 --- a/flutter/lib/desktop/pages/file_manager_page.dart +++ b/flutter/lib/desktop/pages/file_manager_page.dart @@ -286,8 +286,9 @@ class _FileManagerPageState extends State rows: filteredEntries.map((entry) { final sizeStr = entry.isFile ? readableFileSize(entry.size.toDouble()) : ""; - final lastModifiedStr = - "${entry.lastModified().toString().replaceAll(".000", "")} "; + final lastModifiedStr = entry.isDrive + ? " " + : "${entry.lastModified().toString().replaceAll(".000", "")} "; return DataRow( key: ValueKey(entry.name), onSelectChanged: (s) { @@ -810,9 +811,19 @@ class _FileManagerPageState extends State final peerPlatform = (await bind.sessionGetPlatform( id: _ffi.id, isRemote: !isLocal)) .toLowerCase(); - final List menuItems; + final List menuItems = [ + MenuEntryButton( + childBuilder: (TextStyle? style) => Text( + '/', + style: style, + ), + proc: () { + openDirectory('/', isLocal: isLocal); + }, + dismissOnClicked: true), + MenuEntryDivider() + ]; if (peerPlatform == "windows") { - menuItems = []; var loadingTag = ""; if (!isLocal) { loadingTag = _ffi.dialogManager.showLoading("Waiting"); @@ -837,19 +848,6 @@ class _FileManagerPageState extends State _ffi.dialogManager.dismissByTag(loadingTag); } } - } else { - menuItems = [ - MenuEntryButton( - childBuilder: (TextStyle? style) => Text( - '/', - style: style, - ), - proc: () { - openDirectory('/', isLocal: isLocal); - }, - dismissOnClicked: true), - MenuEntryDivider() - ]; } mod_menu.showMenu( diff --git a/flutter/lib/models/file_model.dart b/flutter/lib/models/file_model.dart index a95e44ddf..c7d712eb5 100644 --- a/flutter/lib/models/file_model.dart +++ b/flutter/lib/models/file_model.dart @@ -1178,11 +1178,13 @@ class SelectedItems { } } -// code from file_manager pkg after edit +// edited from [https://github.com/DevsOnFlutter/file_manager/blob/c1bf7f0225b15bcb86eba602c60acd5c4da90dd8/lib/file_manager.dart#L22] List _sortList(List list, SortBy sortType, bool ascending) { if (sortType == SortBy.Name) { // making list of only folders. - final dirs = list.where((element) => element.isDirectory).toList(); + final dirs = list + .where((element) => element.isDirectory || element.isDrive) + .toList(); // sorting folder list by name. dirs.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));