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,16 +177,39 @@ 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,
textAlign: TextAlign.right,
);
return CardX( return CardX(
child: ListTile( child: ListTile(
leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file), leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file),
title: Text(file.filename), title: Text(file.filename),
trailing: trailing, subtitle: isDir ? Text('${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}', style: UIs.textGrey) :
Text('${(file.attr.size ?? 0).bytes2Str}\n${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}', style: UIs.textGrey),
onTap: () {
beforeTap?.call();
if (isDir) {
_status.path.path = file.filename;
_listDir();
} else {
_onItemPress(file, true);
}
},
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), subtitle: isDir ? null : Text((file.attr.size ?? 0).bytes2Str, style: UIs.textGrey),
onTap: () { onTap: () {
beforeTap?.call(); beforeTap?.call();
@@ -205,6 +228,7 @@ extension _UI on _SftpPageState {
); );
} }
} }
}
extension _Actions on _SftpPageState { extension _Actions on _SftpPageState {
void _onItemPress(SftpName file, bool notDir) { void _onItemPress(SftpName file, bool notDir) {