mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-22 03:44:13 +08:00
Update gallery page for desktop
This commit is contained in:
@@ -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)),
|
||||
|
||||
@@ -64,6 +64,7 @@ class _Thumbnail extends State<Thumbnail> {
|
||||
String _dir = "";
|
||||
Color? _iconColor;
|
||||
double? _iconSize;
|
||||
bool _disposed = false;
|
||||
Future<void> _fetchData() async {
|
||||
try {
|
||||
_cancel = CancelToken();
|
||||
@@ -135,11 +136,13 @@ class _Thumbnail extends State<Thumbnail> {
|
||||
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<Thumbnail> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_disposed = true;
|
||||
_cancel?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -36,5 +36,9 @@
|
||||
"sortByGid": "按画廊ID排序",
|
||||
"asc": "升序",
|
||||
"desc": "降序",
|
||||
"saveAs": "另存为"
|
||||
"saveAs": "另存为",
|
||||
"posted": "上传时间",
|
||||
"visible": "可见性",
|
||||
"yes": "是",
|
||||
"no": "否"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user