Update Gallery Page

This commit is contained in:
2023-09-14 22:21:41 +08:00
parent 5b453b3e66
commit 932c56a377
4 changed files with 56 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
import '../api/gallery.dart';
import '../main.dart';
import '../utils/filesize.dart';
import 'tags.dart';
import 'thumbnail.dart';
@@ -95,6 +96,21 @@ class GalleryInfoDesktop extends StatelessWidget {
gData.meta.expunged ? i18n.no : i18n.yes,
fontSize: 12,
),
_KeyValue(
"${i18n.fileSize}${i18n.colon}",
getFileSize(gData.meta.filesize),
fontSize: 12,
),
_KeyValue(
"${i18n.pageLength}${i18n.colon}",
i18n.pages(gData.meta.filecount),
fontSize: 12,
),
_KeyValue(
"${i18n.gid}${i18n.colon}",
gData.meta.gid.toString(),
fontSize: 12,
),
])),
const VerticalDivider(indent: 10, endIndent: 10),
Expanded(child: TagsPanel(gData.tags)),

View File

@@ -40,5 +40,17 @@
"posted": "Posted",
"visible": "Visible",
"yes": "Yes",
"no": "No"
"no": "No",
"fileSize": "File Size",
"pageLength": "Length",
"pages": "{value} pages",
"@pages": {
"placeholders": {
"value": {
"type": "int",
"format": "decimalPattern"
}
}
},
"gid": "Gallery Id"
}

View File

@@ -40,5 +40,17 @@
"posted": "上传时间",
"visible": "可见性",
"yes": "是",
"no": "否"
"no": "否",
"fileSize": "文件大小",
"pageLength": "页数",
"pages": "{value} 页",
"@pages": {
"placeholders": {
"value": {
"type": "int",
"format": "decimalPattern"
}
}
},
"gid": "画廊ID"
}

14
lib/utils/filesize.dart Normal file
View File

@@ -0,0 +1,14 @@
const suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const suffixesB = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
String getFileSize(int size, {int fractionDigits = 2, bool base1024 = true}) {
final suffix = base1024 ? suffixesB : suffixes;
final base = base1024 ? 1024.0 : 1000.0;
var n = size.toDouble();
int ind = 0;
while (n >= base && ind < suffix.length - 1) {
n /= base;
ind++;
}
return '${n.toStringAsFixed(fractionDigits)} ${suffix[ind]}';
}