新增标签自主控制功能

This commit is contained in:
DelLevin-Home
2026-03-12 16:13:13 +08:00
parent 0f221456cb
commit 19e530577b
10 changed files with 543 additions and 76 deletions

View File

@@ -42,26 +42,9 @@ class BookListItem extends StatelessWidget {
const SizedBox(height: 4),
// 评分
// 评分 - 5星显示
if (book.rating != null)
Row(
children: [
const Icon(
Icons.star,
size: 12,
color: Color(0xFFFFB800),
),
const SizedBox(width: 2),
Text(
book.rating!.toStringAsFixed(1),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Color(0xFF666666),
),
),
],
)
_buildStarRating(book.rating!)
else
const SizedBox(height: 16),
],
@@ -99,6 +82,50 @@ class BookListItem extends StatelessWidget {
);
}
/// 构建5星评分显示评分范围1-10每星2分
Widget _buildStarRating(double rating) {
// 将10分制转换为5星制
final starValue = rating / 2;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
// 5个星星
...List.generate(5, (index) {
final starIndex = index + 1;
IconData iconData;
if (starValue >= starIndex) {
// 满星
iconData = Icons.star;
} else if (starValue >= starIndex - 0.5) {
// 半星
iconData = Icons.star_half;
} else {
// 空星
iconData = Icons.star_border;
}
return Icon(
iconData,
size: 12,
color: const Color(0xFFFFB800),
);
}),
const SizedBox(width: 4),
// 评分数字
Text(
rating.toStringAsFixed(1),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Color(0xFF666666),
),
),
],
);
}
/// 显示删除确认对话框
void _showDeleteDialog(BuildContext context) {
showDialog(