feat: Automatic line wrapping of time (#973)

This commit is contained in:
lxdklp
2025-12-07 17:14:45 +08:00
committed by GitHub
parent 038f0d4d77
commit c5cbb12ac3

View File

@@ -177,32 +177,56 @@ extension _UI on _SftpPageState {
Widget _buildItem(SftpName file, {VoidCallback? beforeTap}) { Widget _buildItem(SftpName file, {VoidCallback? beforeTap}) {
final isDir = file.attr.isDirectory; final isDir = file.attr.isDirectory;
final trailing = Text( final double screenWidth = MediaQuery.of(context).size.width;
'${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}', if (screenWidth < 350) {
style: UIs.textGrey, return CardX(
textAlign: TextAlign.right, child: ListTile(
); leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file),
return CardX( title: Text(file.filename),
child: ListTile( subtitle: isDir ? Text('${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}', style: UIs.textGrey) :
leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file), Text('${(file.attr.size ?? 0).bytes2Str}\n${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}', style: UIs.textGrey),
title: Text(file.filename), onTap: () {
trailing: trailing, beforeTap?.call();
subtitle: isDir ? null : Text((file.attr.size ?? 0).bytes2Str, style: UIs.textGrey), if (isDir) {
onTap: () { _status.path.path = file.filename;
beforeTap?.call(); _listDir();
if (isDir) { } else {
_status.path.path = file.filename; _onItemPress(file, true);
_listDir(); }
} else { },
_onItemPress(file, true); onLongPress: () {
} beforeTap?.call();
}, _onItemPress(file, !isDir);
onLongPress: () { },
beforeTap?.call(); ),
_onItemPress(file, !isDir); );
}, } else {
), return CardX(
); child: ListTile(
leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file),
title: Text(file.filename),
trailing: Text(
'${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}',
style: UIs.textGrey,
textAlign: TextAlign.right,
),
subtitle: isDir ? null : Text((file.attr.size ?? 0).bytes2Str, style: UIs.textGrey),
onTap: () {
beforeTap?.call();
if (isDir) {
_status.path.path = file.filename;
_listDir();
} else {
_onItemPress(file, true);
}
},
onLongPress: () {
beforeTap?.call();
_onItemPress(file, !isDir);
},
),
);
}
} }
} }