💄 Optimize attachment previewer in editing

This commit is contained in:
2025-09-01 00:45:35 +08:00
parent 3417c51a3b
commit 43787bb813
4 changed files with 42 additions and 22 deletions

9
lib/utils/format.dart Normal file
View File

@@ -0,0 +1,9 @@
String formatFileSize(int bytes) {
if (bytes <= 0) return '0 B';
if (bytes < 1024) return '$bytes B';
if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(2)} KB';
if (bytes < 1024 * 1024 * 1024) {
return '${(bytes / (1024 * 1024)).toStringAsFixed(2)} MB';
}
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
}