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}) {
final isDir = file.attr.isDirectory;
final trailing = Text(
'${_getTime(file.attr.modifyTime)}\n${file.attr.mode?.str ?? ''}',
style: UIs.textGrey,
textAlign: TextAlign.right,
);
final double screenWidth = MediaQuery.of(context).size.width;
if (screenWidth < 350) {
return CardX(
child: ListTile(
leading: Icon(isDir ? Icons.folder_outlined : Icons.insert_drive_file),
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),
onTap: () {
beforeTap?.call();
@@ -205,6 +228,7 @@ extension _UI on _SftpPageState {
);
}
}
}
extension _Actions on _SftpPageState {
void _onItemPress(SftpName file, bool notDir) {