diff --git a/lib/components/rate.dart b/lib/components/rate.dart index d522153..9689b5a 100644 --- a/lib/components/rate.dart +++ b/lib/components/rate.dart @@ -1,13 +1,16 @@ import 'package:flutter/material.dart'; class Rate extends StatelessWidget { - const Rate(this.rate, {super.key, this.fontSize}); + const Rate(this.rate, {super.key, this.fontSize, this.selectable = false}); final double rate; final double? fontSize; + final bool selectable; @override Widget build(BuildContext context) { final cs = Theme.of(context).colorScheme; + final style = TextStyle(color: cs.secondary, fontSize: fontSize); + final t = " $rate"; return Row( children: [ for (var i = 1; i < 6; i++) @@ -20,8 +23,7 @@ class Rate extends StatelessWidget { color: cs.primary, size: fontSize, ), - Text(" $rate", - style: TextStyle(color: cs.secondary, fontSize: fontSize)), + selectable ? SelectableText(t, style: style) : Text(t, style: style), ], ); } diff --git a/lib/dialog/task_page.dart b/lib/dialog/task_page.dart index 88b43ac..4d5f53c 100644 --- a/lib/dialog/task_page.dart +++ b/lib/dialog/task_page.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:go_router/go_router.dart'; +import 'package:intl/intl.dart'; import 'package:percent_indicator/linear_percent_indicator.dart'; import '../api/task.dart'; +import '../components/rate.dart'; import '../globals.dart'; +import '../main.dart'; import '../utils/duration.dart'; import '../utils/filesize.dart'; @@ -242,6 +245,53 @@ class _TaskPage extends State { ); } + bool get haveMetaInfo { + if (!tasks.tasksList.contains(widget.id)) return false; + final task = tasks.tasks[widget.id]!; + return task.base.type == TaskType.download && + tasks.meta.containsKey(task.base.gid); + } + + Widget _buildMetaInfo(BuildContext context) { + if (!haveMetaInfo) return Container(); + final task = tasks.tasks[widget.id]!; + final meta = tasks.meta[task.base.gid]!; + final i18n = AppLocalizations.of(context)!; + final locale = MainApp.of(context).lang.toLocale().toString(); + DateTime? posted; + final r = int.tryParse(meta.posted); + if (r != null) { + posted = DateTime.fromMillisecondsSinceEpoch(r! * 1000); + } + final cs = Theme.of(context).colorScheme; + double? rating = double.tryParse(meta.rating); + return Column(key: ValueKey("task_detail_meta_${widget.id}"), children: [ + _KeyValue(i18n.title2, meta.title, fontSize: 16), + _KeyValue(i18n.titleJpn, meta.titleJpn, fontSize: 16), + _KeyValue(i18n.category, meta.category, fontSize: 16), + _KeyValue(i18n.uploader, meta.uploader, fontSize: 16), + posted != null + ? _KeyValue( + i18n.posted, DateFormat.yMd(locale).add_jms().format(posted), + fontSize: 16) + : Container(), + _KeyValue(i18n.pageLength, meta.filecount, fontSize: 16), + _KeyValue(i18n.fileSize, getFileSize(meta.filesize), fontSize: 16), + _KeyValue(i18n.visible, meta.expunged ? i18n.no : i18n.yes, fontSize: 16), + rating != null + ? Row(children: [ + SizedBox( + width: 80, + child: Center( + child: Text(i18n.rating, + textAlign: TextAlign.center, + style: TextStyle(color: cs.primary, fontSize: 16)))), + Expanded(child: Rate(rating!, fontSize: 16, selectable: true)), + ]) + : Container(), + ]); + } + @override Widget build(BuildContext context) { tryInitApi(context); @@ -282,6 +332,11 @@ class _TaskPage extends State { : Container()), SliverToBoxAdapter(child: _buildProgress(context)), _buildMoreProgress(context), + SliverToBoxAdapter( + child: haveMetaInfo + ? Divider(indent: indent, endIndent: indent) + : Container()), + SliverToBoxAdapter(child: _buildMetaInfo(context)), ], ), ); diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 53824bf..0ef015b 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -189,5 +189,7 @@ "type": "int" } } - } + }, + "category": "Category", + "uploader": "Uploader" } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 2009046..159d818 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -189,5 +189,7 @@ "type": "int" } } - } + }, + "category": "分类", + "uploader": "上传者" }