generated from dellevin/template
新增标签自主控制功能
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -2,14 +2,36 @@ import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../utils/user_prefs.dart';
|
||||
import '../utils/toast_util.dart';
|
||||
import '../models/data_models.dart';
|
||||
|
||||
/// 自定义左侧弹出菜单 - 极简主义设计
|
||||
class CustomDrawer extends StatelessWidget {
|
||||
CustomDrawer({super.key});
|
||||
class CustomDrawer extends StatefulWidget {
|
||||
const CustomDrawer({super.key});
|
||||
|
||||
@override
|
||||
State<CustomDrawer> createState() => _CustomDrawerState();
|
||||
}
|
||||
|
||||
class _CustomDrawerState extends State<CustomDrawer> {
|
||||
String _version = '0.1.5';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadVersionInfo();
|
||||
}
|
||||
|
||||
/// 加载版本信息
|
||||
Future<void> _loadVersionInfo() async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
setState(() {
|
||||
_version = packageInfo.version;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,9 +65,9 @@ class CustomDrawer extends StatelessWidget {
|
||||
// 底部版本信息
|
||||
Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: const Text(
|
||||
'MookNote v0.1.5',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
'MookNote v$_version',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
|
||||
@@ -42,26 +42,9 @@ class MovieListItem extends StatelessWidget {
|
||||
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// 评分
|
||||
// 评分 - 5星显示
|
||||
if (movie.rating != null)
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.star,
|
||||
size: 12,
|
||||
color: Color(0xFFFFB800),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
movie.rating!.toStringAsFixed(1),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
_buildStarRating(movie.rating!)
|
||||
else
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
@@ -99,6 +82,50 @@ class MovieListItem 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(
|
||||
|
||||
Reference in New Issue
Block a user