add rating

This commit is contained in:
2023-09-22 16:40:30 +08:00
parent f7ebc10617
commit 50ff4b3fdd
5 changed files with 44 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import 'package:intl/intl.dart';
import '../api/gallery.dart';
import '../main.dart';
import '../utils/filesize.dart';
import 'rate.dart';
import 'tags.dart';
import 'thumbnail.dart';
@@ -112,6 +113,17 @@ class GalleryInfoDesktop extends StatelessWidget {
gData.meta.gid.toString(),
fontSize: 12,
),
Row(
children: [
SizedBox(
width: 60,
child: Text("${i18n.rating}${i18n.colon}",
style: TextStyle(
color: cs.primary,
fontSize: 12))),
Rate(gData.meta.rating),
],
)
])),
const VerticalDivider(indent: 10, endIndent: 10),
Expanded(child: TagsPanel(gData.tags)),

26
lib/components/rate.dart Normal file
View File

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
class Rate extends StatelessWidget {
const Rate(this.rate, {Key? key}) : super(key: key);
final double rate;
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Row(
children: [
for (var i = 1; i < 6; i++)
Icon(
i <= rate + 0.25
? Icons.star
: i > rate + 0.75
? Icons.star_border
: Icons.star_half,
color: cs.primary,
size: 12,
),
Text(" $rate", style: TextStyle(color: cs.secondary, fontSize: 12)),
],
);
}
}

View File

@@ -17,8 +17,9 @@ class ScrollParent extends StatelessWidget {
}
if (controller.offset + value.overscroll >=
controller.position.maxScrollExtent) {
if (controller.offset != controller.position.maxScrollExtent)
if (controller.offset != controller.position.maxScrollExtent) {
controller.jumpTo(controller.position.maxScrollExtent);
}
return true;
}
controller.jumpTo(controller.offset + value.overscroll);

View File

@@ -84,5 +84,6 @@
"exportAd": "Export pages which marked as ads",
"maxZipFilenameLength": "Maximum length of filenames in Zip files",
"downloadComplete": "Download completed.",
"downloadZipFailed": "Failed to download ZIP file."
"downloadZipFailed": "Failed to download ZIP file.",
"rating": "Rating"
}

View File

@@ -84,5 +84,6 @@
"exportAd": "导出标记为广告的页面",
"maxZipFilenameLength": "Zip文件中文件名的最大长度",
"downloadComplete": "下载完毕。",
"downloadZipFailed": "Zip文件下载失败。"
"downloadZipFailed": "Zip文件下载失败。",
"rating": "评分"
}