feat(local file page): Display server names for server folders (#996)
* feat(local file page): Display server names for server folders In the local file list, server folders will display their corresponding server names, enhancing the user experience. * fix(storage page): Use ref.read instead of ref.watch to fetch the server list Avoid unnecessary watch operations during construction, reducing potential performance overhead
This commit is contained in:
@@ -140,11 +140,23 @@ class _LocalFilePageState extends ConsumerState<LocalFilePage> with AutomaticKee
|
|||||||
required FileStat stat,
|
required FileStat stat,
|
||||||
required bool isDir,
|
required bool isDir,
|
||||||
}) {
|
}) {
|
||||||
|
final isServerFolder = isDir && file.parent.path == Paths.file;
|
||||||
|
String? serverName;
|
||||||
|
if (isServerFolder) {
|
||||||
|
final servers = ref.read(serversProvider).servers;
|
||||||
|
final server = servers[fileName];
|
||||||
|
if (server != null) {
|
||||||
|
serverName = server.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return CardX(
|
return CardX(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: isDir ? const Icon(Icons.folder_open) : const Icon(Icons.insert_drive_file),
|
leading: isDir ? const Icon(Icons.folder_open) : const Icon(Icons.insert_drive_file),
|
||||||
title: Text(fileName),
|
title: Text(serverName ?? fileName),
|
||||||
subtitle: isDir ? null : Text(stat.size.bytes2Str, style: UIs.textGrey),
|
subtitle: isDir
|
||||||
|
? (serverName != null ? Text(fileName, style: UIs.textGrey) : null)
|
||||||
|
: Text(stat.size.bytes2Str, style: UIs.textGrey),
|
||||||
trailing: Text(stat.modified.ymdhms(), style: UIs.textGrey),
|
trailing: Text(stat.modified.ymdhms(), style: UIs.textGrey),
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
|
|||||||
Reference in New Issue
Block a user