diff --git a/lib/components/gallery_info_desktop.dart b/lib/components/gallery_info_desktop.dart index 50bc358..e4db358 100644 --- a/lib/components/gallery_info_desktop.dart +++ b/lib/components/gallery_info_desktop.dart @@ -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)), diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index a401404..e69fd5a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -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" } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 59859cc..e50d941 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -40,5 +40,17 @@ "posted": "上传时间", "visible": "可见性", "yes": "是", - "no": "否" + "no": "否", + "fileSize": "文件大小", + "pageLength": "页数", + "pages": "{value} 页", + "@pages": { + "placeholders": { + "value": { + "type": "int", + "format": "decimalPattern" + } + } + }, + "gid": "画廊ID" } diff --git a/lib/utils/filesize.dart b/lib/utils/filesize.dart new file mode 100644 index 0000000..2d2d112 --- /dev/null +++ b/lib/utils/filesize.dart @@ -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]}'; +}