diff --git a/lib/components/gallery_info_desktop.dart b/lib/components/gallery_info_desktop.dart index 5b456ac..50bc358 100644 --- a/lib/components/gallery_info_desktop.dart +++ b/lib/components/gallery_info_desktop.dart @@ -1,9 +1,39 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:intl/intl.dart'; import '../api/gallery.dart'; +import '../main.dart'; import 'tags.dart'; import 'thumbnail.dart'; +class _KeyValue extends StatelessWidget { + const _KeyValue(this.name, this.value, + {Key? key, this.maxLines, this.minLines, this.fontSize}) + : super(key: key); + final String name; + final String value; + final int? maxLines; + final int? minLines; + final double? fontSize; + + @override + Widget build(BuildContext context) { + final cs = Theme.of(context).colorScheme; + return Row(children: [ + SizedBox( + width: 60, + child: Text(name, + style: TextStyle(color: cs.primary, fontSize: fontSize))), + Expanded( + child: SelectableText(value, + style: TextStyle(color: cs.secondary, fontSize: fontSize), + maxLines: maxLines, + minLines: minLines), + ) + ]); + } +} + class GalleryInfoDesktop extends StatelessWidget { const GalleryInfoDesktop(this.gData, {Key? key, this.fileId, this.controller}) : super(key: key); @@ -14,6 +44,8 @@ class GalleryInfoDesktop extends StatelessWidget { @override Widget build(BuildContext context) { final cs = Theme.of(context).colorScheme; + final i18n = AppLocalizations.of(context)!; + final locale = MainApp.of(context).lang.toLocale().toString(); return Container( alignment: Alignment.topCenter, child: SizedBox( @@ -45,8 +77,24 @@ class GalleryInfoDesktop extends StatelessWidget { SizedBox( width: 170, child: Column(children: [ - SelectableText(gData.meta.category), - SelectableText(gData.meta.uploader), + SelectableText(gData.meta.category, + style: TextStyle(color: cs.secondary)), + SelectableText(gData.meta.uploader, + style: TextStyle(color: cs.secondary)), + _KeyValue( + "${i18n.posted}${i18n.colon}", + DateFormat.yMd(locale) + .add_jms() + .format(gData.meta.posted), + maxLines: 2, + minLines: 1, + fontSize: 12, + ), + _KeyValue( + "${i18n.visible}${i18n.colon}", + gData.meta.expunged ? i18n.no : i18n.yes, + fontSize: 12, + ), ])), const VerticalDivider(indent: 10, endIndent: 10), Expanded(child: TagsPanel(gData.tags)), diff --git a/lib/components/thumbnail.dart b/lib/components/thumbnail.dart index a45be7e..55e8a74 100644 --- a/lib/components/thumbnail.dart +++ b/lib/components/thumbnail.dart @@ -64,6 +64,7 @@ class _Thumbnail extends State { String _dir = ""; Color? _iconColor; double? _iconSize; + bool _disposed = false; Future _fetchData() async { try { _cancel = CancelToken(); @@ -135,11 +136,13 @@ class _Thumbnail extends State { center: Offset(i.width / 2, i.height / 2), width: iconSize, height: iconSize)); - setState(() { - _iconColor = pattle.colors.first.computeLuminance() > 0.5 - ? Colors.black - : Colors.white; - }); + if (!_disposed) { + setState(() { + _iconColor = pattle.colors.first.computeLuminance() > 0.5 + ? Colors.black + : Colors.white; + }); + } } finally { i.dispose(); } @@ -155,6 +158,7 @@ class _Thumbnail extends State { @override void dispose() { + _disposed = true; _cancel?.cancel(); super.dispose(); } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e2b6016..a401404 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -36,5 +36,9 @@ "sortByGid": "Sort by gallery id", "asc": "Ascending", "desc": "Descending", - "saveAs": "Save As" + "saveAs": "Save As", + "posted": "Posted", + "visible": "Visible", + "yes": "Yes", + "no": "No" } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index b2d697b..59859cc 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -36,5 +36,9 @@ "sortByGid": "按画廊ID排序", "asc": "升序", "desc": "降序", - "saveAs": "另存为" + "saveAs": "另存为", + "posted": "上传时间", + "visible": "可见性", + "yes": "是", + "no": "否" }