generated from dellevin/template
加入新图标,优化通知栏,统计界面加入标签词云
This commit is contained in:
@@ -57,15 +57,21 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
widget.appProvider.loadThemeMode();
|
||||
widget.appProvider.addListener(_onThemeChanged);
|
||||
_updateSystemUI(widget.appProvider.themeMode);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.appProvider.removeListener(_onThemeChanged);
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onThemeChanged() {
|
||||
_updateSystemUI(widget.appProvider.themeMode);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
@@ -85,6 +91,8 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
}
|
||||
final isDark = brightness == Brightness.dark;
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
|
||||
systemNavigationBarColor: isDark ? const Color(0xFF1A1A1A) : Colors.white,
|
||||
systemNavigationBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
|
||||
));
|
||||
@@ -100,7 +108,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
],
|
||||
child: Consumer<AppProvider>(
|
||||
builder: (context, provider, _) {
|
||||
_updateSystemUI(provider.themeMode);
|
||||
return MaterialApp(
|
||||
title: 'MookNote',
|
||||
debugShowCheckedModeBanner: false,
|
||||
|
||||
@@ -18,6 +18,7 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
|
||||
final List<Map<String, String>> _icons = [
|
||||
{'name': 'app_icon', 'label': '默认图标'},
|
||||
{'name': 'app_icon2', 'label': '风格二'},
|
||||
{'name': 'app_icon_m', 'label': '风格三'},
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -28,35 +29,22 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
|
||||
|
||||
Future<void> _loadCurrentIcon() async {
|
||||
final nativeIcon = await AppIconChannel.getCurrentIcon();
|
||||
setState(() {
|
||||
_currentIconName = nativeIcon;
|
||||
});
|
||||
setState(() => _currentIconName = nativeIcon);
|
||||
}
|
||||
|
||||
Future<void> _selectIcon(String iconName) async {
|
||||
if (iconName == _currentIconName) return;
|
||||
|
||||
try {
|
||||
final success = await AppIconChannel.switchIcon(iconName);
|
||||
|
||||
if (success) {
|
||||
await _userPrefs.setAppIconName(iconName);
|
||||
setState(() {
|
||||
_currentIconName = iconName;
|
||||
});
|
||||
|
||||
if (mounted) {
|
||||
ToastUtil.show(context, '图标已切换,请返回桌面查看');
|
||||
}
|
||||
setState(() => _currentIconName = iconName);
|
||||
if (mounted) ToastUtil.show(context, '图标已切换,请返回桌面查看');
|
||||
} else {
|
||||
if (mounted) {
|
||||
ToastUtil.show(context, '图标切换失败');
|
||||
}
|
||||
if (mounted) ToastUtil.show(context, '图标切换失败');
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ToastUtil.show(context, '切换出错: $e');
|
||||
}
|
||||
if (mounted) ToastUtil.show(context, '切换出错: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,66 +52,68 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Scaffold(
|
||||
backgroundColor: colors.surface,
|
||||
backgroundColor: colors.surfaceContainerHigh,
|
||||
appBar: AppBar(
|
||||
title: const Text('应用图标'),
|
||||
),
|
||||
body: GridView.builder(
|
||||
padding: const EdgeInsets.all(24),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 0.85,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
),
|
||||
body: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
itemCount: _icons.length,
|
||||
itemBuilder: (context, index) {
|
||||
final icon = _icons[index];
|
||||
final isSelected = _currentIconName == icon['name'];
|
||||
|
||||
return GestureDetector(
|
||||
return InkWell(
|
||||
onTap: () => _selectIcon(icon['name']!),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? colors.outlineVariant : colors.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isSelected ? colors.primary : colors.outlineVariant,
|
||||
width: isSelected ? 2 : 1,
|
||||
color: isSelected ? colors.primary : Colors.transparent,
|
||||
width: isSelected ? 2 : 0,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/icon/${icon['name']}.png',
|
||||
Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: colors.outlineVariant, width: 0.5),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Image.asset(
|
||||
'assets/icon/${icon['name']}.png',
|
||||
width: 64,
|
||||
height: 64,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
color: colors.outlineVariant,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(Icons.image_not_supported, color: colors.onSurface.withValues(alpha: 0.4)),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
icon['label']!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: colors.onSurface,
|
||||
color: colors.surfaceContainerHighest,
|
||||
child: Icon(Icons.image_not_supported, size: 24, color: colors.onSurface.withValues(alpha: 0.3)),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isSelected) ...[
|
||||
const SizedBox(height: 4),
|
||||
Icon(Icons.check_circle, size: 18, color: colors.primary),
|
||||
],
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
icon['label']!,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
Icon(Icons.check_circle, size: 22, color: colors.primary)
|
||||
else
|
||||
Icon(Icons.radio_button_unchecked, size: 22, color: colors.onSurface.withValues(alpha: 0.2)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
import '../../utils/user_prefs.dart';
|
||||
import 'movie_reviews_page.dart';
|
||||
import 'movie_posters_page.dart';
|
||||
import 'movie_share_page.dart';
|
||||
@@ -24,15 +25,17 @@ class MovieDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MovieDetailPageState extends State<MovieDetailPage> {
|
||||
late bool _showExactDate;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_refreshMovieData();
|
||||
void initState() {
|
||||
super.initState();
|
||||
_showExactDate = UserPrefs().showExactReleaseDate;
|
||||
}
|
||||
|
||||
void _refreshMovieData() {
|
||||
final provider = context.read<AppProvider>();
|
||||
provider.loadMovies();
|
||||
void _toggleDateDisplay() {
|
||||
setState(() => _showExactDate = !_showExactDate);
|
||||
UserPrefs().setShowExactReleaseDate(_showExactDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -275,11 +278,23 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (movie.releaseDate != null)
|
||||
Text(
|
||||
'${movie.releaseDate!.year}年${movie.releaseDate!.month.toString().padLeft(2, '0')}月上映',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
GestureDetector(
|
||||
onTap: _toggleDateDisplay,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_showExactDate
|
||||
? '${movie.releaseDate!.year}年${movie.releaseDate!.month.toString().padLeft(2, '0')}月${movie.releaseDate!.day.toString().padLeft(2, '0')}日上映'
|
||||
: '${movie.releaseDate!.year}年${movie.releaseDate!.month.toString().padLeft(2, '0')}月上映',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(Icons.tune, size: 14, color: colors.onSurface.withValues(alpha: 0.2)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
import 'movie_review_form_page.dart';
|
||||
|
||||
/// 影评详情页
|
||||
@@ -28,162 +30,149 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
|
||||
_review = widget.review;
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_refreshReviewData();
|
||||
}
|
||||
|
||||
Future<void> _refreshReviewData() async {
|
||||
final provider = context.read<AppProvider>();
|
||||
final reviews = await provider.getMovieReviews(widget.movieId);
|
||||
final updatedReview = reviews
|
||||
.where((r) => r.id == widget.review.id)
|
||||
.firstOrNull;
|
||||
final updatedReview = reviews.where((r) => r.id == widget.review.id).firstOrNull;
|
||||
if (updatedReview != null && updatedReview.id == _review.id) {
|
||||
setState(() {
|
||||
_review = updatedReview;
|
||||
});
|
||||
setState(() => _review = updatedReview);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Scaffold(
|
||||
backgroundColor: colors.surface,
|
||||
appBar: AppBar(
|
||||
title: const Text('影评详情'),
|
||||
actions: [
|
||||
// 编辑按钮
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
onPressed: () => _navigateToEdit(context),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 影评内容
|
||||
Text(
|
||||
_review.content,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: colors.onSurface,
|
||||
height: 1.8,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 分隔线
|
||||
Container(
|
||||
height: 0.5,
|
||||
color: colors.outline,
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 影评人
|
||||
_buildInfoRow(
|
||||
icon: Icons.person_outline,
|
||||
label: '影评人:',
|
||||
value: _review.reviewer.isNotEmpty ? _review.reviewer : '匿名',
|
||||
colors: colors,
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 来源
|
||||
if (_review.source.isNotEmpty)
|
||||
_buildInfoRow(
|
||||
icon: Icons.source_outlined,
|
||||
label: '来源:',
|
||||
value: _review.source,
|
||||
colors: colors,
|
||||
),
|
||||
|
||||
if (_review.source.isNotEmpty) const SizedBox(height: 16),
|
||||
|
||||
// 类型
|
||||
_buildInfoRow(
|
||||
icon: Icons.category_outlined,
|
||||
label: '类型:',
|
||||
value: _review.typeText,
|
||||
colors: colors,
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 时间
|
||||
_buildInfoRow(
|
||||
icon: Icons.access_time,
|
||||
label: '时间:',
|
||||
value: _formatDate(_review.createdAt),
|
||||
colors: colors,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
Movie? _getMovie() {
|
||||
return context.read<AppProvider>().movies.where((m) => m.id == widget.movieId).firstOrNull;
|
||||
}
|
||||
|
||||
/// 构建信息行
|
||||
Widget _buildInfoRow({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
required ColorScheme colors,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// 固定宽度容器,以"影评人:"的最大宽度为准
|
||||
SizedBox(
|
||||
width: 64,
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
Future<void> _deleteReview() async {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: colors.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)),
|
||||
content: Text('确定要删除这条影评吗?', style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(ctx, false), child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.5)))),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: colors.error, foregroundColor: colors.onError, elevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
|
||||
child: const Text('删除'),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed == true) {
|
||||
await context.read<AppProvider>().removeMovieReview(_review.id);
|
||||
if (mounted) { ToastUtil.show(context, '已删除'); Navigator.pop(context); }
|
||||
}
|
||||
}
|
||||
|
||||
void _navigateToEdit(BuildContext context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => MovieReviewFormPage(movieId: widget.movieId, review: _review)),
|
||||
).then((_) => _refreshReviewData());
|
||||
}
|
||||
|
||||
String _formatDate(DateTime date) {
|
||||
return '${date.year}.${date.month.toString().padLeft(2, '0')}.${date.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
void _navigateToEdit(BuildContext context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MovieReviewFormPage(
|
||||
movieId: widget.movieId,
|
||||
review: _review,
|
||||
),
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final movie = _getMovie();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: colors.surfaceContainerHigh,
|
||||
appBar: AppBar(
|
||||
title: const Text('影评详情'),
|
||||
actions: [
|
||||
IconButton(icon: const Icon(Icons.edit_outlined, size: 20), onPressed: () => _navigateToEdit(context), tooltip: '编辑'),
|
||||
IconButton(icon: Icon(Icons.delete_outline, size: 20, color: colors.error.withValues(alpha: 0.7)), onPressed: _deleteReview, tooltip: '删除'),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
),
|
||||
).then((_) => _refreshReviewData());
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
// ── 电影信息卡片 ──────────────────────
|
||||
if (movie != null) _buildMovieCard(movie, colors),
|
||||
if (movie != null) const SizedBox(height: 16),
|
||||
|
||||
// ── 影评内容卡片 ──────────────────────
|
||||
_buildContentCard(colors),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// ── 元信息卡片 ────────────────────────
|
||||
_buildInfoCard(colors),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMovieCard(Movie movie, ColorScheme colors) => Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(12)),
|
||||
child: Row(children: [
|
||||
Container(
|
||||
width: 52, height: 68,
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(6), color: colors.surfaceContainerHighest),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: movie.posterPath != null
|
||||
? Image.file(File(movie.posterPath!), fit: BoxFit.cover, errorBuilder: (_, __, ___) => Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
: Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(movie.title, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface), maxLines: 2, overflow: TextOverflow.ellipsis),
|
||||
if (movie.rating != null) ...[const SizedBox(height: 4), Row(children: [
|
||||
Icon(Icons.star, size: 14, color: const Color(0xFFFFB800)),
|
||||
const SizedBox(width: 2),
|
||||
Text('${movie.rating}', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
])],
|
||||
])),
|
||||
]),
|
||||
);
|
||||
|
||||
Widget _buildContentCard(ColorScheme colors) => Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(_review.content, style: TextStyle(fontSize: 16, color: colors.onSurface, height: 1.8)),
|
||||
const SizedBox(height: 16),
|
||||
Row(children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
|
||||
decoration: BoxDecoration(color: colors.primary.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(10)),
|
||||
child: Text(_review.typeText, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: colors.primary)),
|
||||
),
|
||||
]),
|
||||
]),
|
||||
);
|
||||
|
||||
Widget _buildInfoCard(ColorScheme colors) => Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(children: [
|
||||
_infoRow(Icons.person_outline, '影评人', _review.reviewer.isNotEmpty ? _review.reviewer : '匿名', colors),
|
||||
Divider(height: 24, color: colors.outlineVariant),
|
||||
if (_review.source.isNotEmpty) ...[
|
||||
_infoRow(Icons.link, '来源', _review.source, colors),
|
||||
const Divider(height: 24),
|
||||
],
|
||||
_infoRow(Icons.access_time, '时间', _formatDate(_review.createdAt), colors),
|
||||
]),
|
||||
);
|
||||
|
||||
Widget _infoRow(IconData icon, String label, String value, ColorScheme colors) => Row(children: [
|
||||
Icon(icon, size: 18, color: colors.onSurface.withValues(alpha: 0.35)),
|
||||
const SizedBox(width: 10),
|
||||
Text(label, style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.4))),
|
||||
const Spacer(),
|
||||
Text(value, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onSurface)),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
|
||||
/// 添加/编辑影评页面 - 极简设计
|
||||
/// 添加/编辑影评页面
|
||||
class MovieReviewFormPage extends StatefulWidget {
|
||||
final String movieId;
|
||||
final MovieReview? review;
|
||||
|
||||
const MovieReviewFormPage({
|
||||
super.key,
|
||||
required this.movieId,
|
||||
this.review,
|
||||
});
|
||||
const MovieReviewFormPage({super.key, required this.movieId, this.review});
|
||||
|
||||
@override
|
||||
State<MovieReviewFormPage> createState() => _MovieReviewFormPageState();
|
||||
@@ -29,11 +26,10 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final review = widget.review;
|
||||
_contentController = TextEditingController(text: review?.content ?? '');
|
||||
_reviewerController = TextEditingController(text: review?.reviewer ?? '');
|
||||
_sourceController = TextEditingController(text: review?.source ?? '');
|
||||
_reviewType = review?.reviewType ?? 1;
|
||||
_contentController = TextEditingController(text: widget.review?.content ?? '');
|
||||
_reviewerController = TextEditingController(text: widget.review?.reviewer ?? '');
|
||||
_sourceController = TextEditingController(text: widget.review?.source ?? '');
|
||||
_reviewType = widget.review?.reviewType ?? 1;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -44,107 +40,92 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Movie? _getMovie() {
|
||||
return context.read<AppProvider>().movies.where((m) => m.id == widget.movieId).firstOrNull;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final isEdit = widget.review != null;
|
||||
final movie = _getMovie();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: colors.surface,
|
||||
appBar: AppBar(
|
||||
title: Text(isEdit ? '编辑影评' : '写影评'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _saveReview,
|
||||
child: const Text(
|
||||
'保存',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
// 顶部信息栏
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: colors.outline, width: 0.5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// 类型选择
|
||||
_buildTypeSelector(colors),
|
||||
const SizedBox(width: 16),
|
||||
// 评论人
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _reviewerController,
|
||||
style: TextStyle(fontSize: 14, color: colors.onSurface),
|
||||
decoration: InputDecoration(
|
||||
hintText: '评论人',
|
||||
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// 来源
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: TextField(
|
||||
controller: _sourceController,
|
||||
style: TextStyle(fontSize: 14, color: colors.onSurface),
|
||||
decoration: InputDecoration(
|
||||
hintText: '来源',
|
||||
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 评论内容区域
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _contentController,
|
||||
maxLines: null,
|
||||
expands: true,
|
||||
textAlignVertical: TextAlignVertical.top,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: colors.onSurface,
|
||||
height: 1.7,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ── 电影信息卡片 ──────────────────
|
||||
if (movie != null) _buildMovieCard(movie, colors),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// ── 类型选择 ──────────────────────
|
||||
Text('影评类型', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.5))),
|
||||
const SizedBox(height: 8),
|
||||
_buildTypeSelector(colors),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// ── 元信息 ────────────────────────
|
||||
_buildMetaField(
|
||||
icon: Icons.person_outline,
|
||||
hint: '评论人(选填)',
|
||||
controller: _reviewerController,
|
||||
colors: colors,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildMetaField(
|
||||
icon: Icons.link,
|
||||
hint: '来源(选填)',
|
||||
controller: _sourceController,
|
||||
colors: colors,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// ── 评论内容 ──────────────────────
|
||||
Text('评论内容', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.5))),
|
||||
const SizedBox(height: 8),
|
||||
_buildContentField(colors),
|
||||
],
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: '写下你的影评...',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
color: colors.onSurface.withValues(alpha: 0.25),
|
||||
),
|
||||
),
|
||||
|
||||
// ── 底部保存按钮 ──────────────────────
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 16, right: 16, top: 12,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
border: Border(top: BorderSide(color: colors.outlineVariant, width: 0.5)),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: _saveReview,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colors.primary,
|
||||
foregroundColor: colors.onPrimary,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
child: Text(isEdit ? '更新影评' : '保存影评',
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return '请输入评论内容';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -153,84 +134,173 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建类型选择器
|
||||
Widget _buildTypeSelector(ColorScheme colors) {
|
||||
return GestureDetector(
|
||||
onTap: () => _showTypeSelector(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: colors.outline),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_reviewType == 1 ? '短评' : '长评',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 16,
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// 电影信息卡片
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/// 显示类型选择
|
||||
void _showTypeSelector() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.transparent,
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
|
||||
builder: (context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Container(
|
||||
color: colors.surface,
|
||||
child: SafeArea(
|
||||
Widget _buildMovieCard(Movie movie, ColorScheme colors) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 56, height: 72,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
color: colors.outlineVariant,
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: movie.posterPath != null
|
||||
? Image.file(File(movie.posterPath!), fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
: Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text('短评'),
|
||||
trailing: _reviewType == 1
|
||||
? Icon(Icons.check, color: colors.onSurface)
|
||||
: null,
|
||||
onTap: () {
|
||||
setState(() => _reviewType = 1);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
Divider(height: 0.5, color: colors.outline),
|
||||
ListTile(
|
||||
title: const Text('长评'),
|
||||
trailing: _reviewType == 2
|
||||
? Icon(Icons.check, color: colors.onSurface)
|
||||
: null,
|
||||
onTap: () {
|
||||
setState(() => _reviewType = 2);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
Text(movie.title, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface), maxLines: 2, overflow: TextOverflow.ellipsis),
|
||||
if (movie.rating != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(children: [
|
||||
Icon(Icons.star, size: 14, color: const Color(0xFFFFB800)),
|
||||
const SizedBox(width: 2),
|
||||
Text('${movie.rating}', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
]),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// 类型选择器(分段按钮)
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Widget _buildTypeSelector(ColorScheme colors) {
|
||||
return SegmentedButton<int>(
|
||||
segments: const [
|
||||
ButtonSegment(value: 1, label: Text('短评'), icon: Icon(Icons.short_text)),
|
||||
ButtonSegment(value: 2, label: Text('长评'), icon: Icon(Icons.menu_book)),
|
||||
],
|
||||
selected: {_reviewType},
|
||||
onSelectionChanged: (v) => setState(() => _reviewType = v.first),
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) return colors.primary;
|
||||
return colors.surfaceContainerHighest;
|
||||
}),
|
||||
foregroundColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) return colors.onPrimary;
|
||||
return colors.onSurface.withValues(alpha: 0.6);
|
||||
}),
|
||||
iconColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) return colors.onPrimary;
|
||||
return colors.onSurface.withValues(alpha: 0.4);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// 元信息输入
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Widget _buildMetaField({
|
||||
required IconData icon,
|
||||
required String hint,
|
||||
required TextEditingController controller,
|
||||
required ColorScheme colors,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: colors.onSurface.withValues(alpha: 0.35)),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
style: TextStyle(fontSize: 14, color: colors.onSurface),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.3)),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// 内容输入区 + 字数统计
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Widget _buildContentField(ColorScheme colors) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _contentController,
|
||||
maxLines: 10,
|
||||
minLines: 6,
|
||||
textAlignVertical: TextAlignVertical.top,
|
||||
style: TextStyle(fontSize: 15, color: colors.onSurface, height: 1.7),
|
||||
decoration: InputDecoration(
|
||||
hintText: '写下你的影评...',
|
||||
hintStyle: TextStyle(fontSize: 15, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.all(14),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) return '请输入评论内容';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 14, bottom: 10),
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
'${_contentController.text.length} 字',
|
||||
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.3)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// 保存
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Future<void> _saveReview() async {
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
|
||||
final now = DateTime.now();
|
||||
|
||||
@@ -258,9 +328,7 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
ToastUtil.show(context, widget.review == null ? '添加成功' : '更新成功');
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
@@ -13,6 +14,7 @@ class StatisticsPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _StatisticsPageState extends State<StatisticsPage> {
|
||||
int _cloudTabIndex = 0; // 0=影视, 1=书籍, 2=笔记
|
||||
bool get _showMovies => UserPrefs().showMovieTab;
|
||||
bool get _showBooks => UserPrefs().showBookTab;
|
||||
bool get _showNotes => UserPrefs().showNoteTab;
|
||||
@@ -50,6 +52,8 @@ class _StatisticsPageState extends State<StatisticsPage> {
|
||||
_buildNoteTagDistribution('笔记标签分布', notes),
|
||||
const SizedBox(height: 28),
|
||||
],
|
||||
_buildTagCloud(movies, books, notes),
|
||||
const SizedBox(height: 28),
|
||||
_buildRatingDistribution('评分分布', movies, books),
|
||||
const SizedBox(height: 28),
|
||||
_buildMonthlyTrend(movies, books, notes),
|
||||
@@ -398,6 +402,88 @@ class _StatisticsPageState extends State<StatisticsPage> {
|
||||
return 5 - diff; // index 0..5 where 0=5 months ago, 5=current month
|
||||
}
|
||||
|
||||
// ─── 标签词云 ──────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildTagCloud(List<Movie> movies, List<Book> books, List<Note> notes) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final tabs = <String>[];
|
||||
if (_showMovies) tabs.add('影视');
|
||||
if (_showBooks) tabs.add('书籍');
|
||||
if (_showNotes) tabs.add('笔记');
|
||||
if (tabs.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
// 确保 cloudTabIndex 在有效范围内
|
||||
if (_cloudTabIndex >= tabs.length) _cloudTabIndex = 0;
|
||||
|
||||
final tagCounts = <String, int>{};
|
||||
switch (tabs[_cloudTabIndex]) {
|
||||
case '影视':
|
||||
for (final m in movies) { for (final g in m.genres) { tagCounts[g] = (tagCounts[g] ?? 0) + 1; } }
|
||||
break;
|
||||
case '书籍':
|
||||
for (final b in books) { for (final g in b.genres) { tagCounts[g] = (tagCounts[g] ?? 0) + 1; } }
|
||||
break;
|
||||
case '笔记':
|
||||
for (final n in notes) { for (final t in n.tags) { tagCounts[t] = (tagCounts[t] ?? 0) + 1; } }
|
||||
break;
|
||||
}
|
||||
|
||||
final sorted = tagCounts.entries.toList()..sort((a, b) => b.value.compareTo(a.value));
|
||||
if (sorted.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
final maxCount = sorted.first.value;
|
||||
final minCount = sorted.last.value;
|
||||
final range = math.max(maxCount - minCount, 1);
|
||||
|
||||
const cloudColors = [
|
||||
Color(0xFFE53935), Color(0xFF4A90D9), Color(0xFF7E57C2),
|
||||
Color(0xFF66BB6A), Color(0xFFFF8F00), Color(0xFF00ACC1),
|
||||
Color(0xFF5C6BC0), Color(0xFF26A69A), Color(0xFF8D6E63),
|
||||
];
|
||||
|
||||
return _buildCard(
|
||||
title: '标签词云',
|
||||
child: Column(children: [
|
||||
// Tab 切换
|
||||
Row(
|
||||
children: tabs.map((t) {
|
||||
final i = tabs.indexOf(t);
|
||||
final selected = _cloudTabIndex == i;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() => _cloudTabIndex = i),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
margin: EdgeInsets.only(right: i < tabs.length - 1 ? 6 : 0),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? colors.primary : colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(t, textAlign: TextAlign.center, style: TextStyle(fontSize: 13, fontWeight: selected ? FontWeight.w600 : FontWeight.w500, color: selected ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.5))),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// 词云
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 6,
|
||||
children: sorted.map((e) {
|
||||
final ratio = (e.value - minCount) / range;
|
||||
final fontSize = (12.0 + ratio * 18.0).roundToDouble();
|
||||
final c = cloudColors[((ratio * (cloudColors.length - 1)).round()).clamp(0, cloudColors.length - 1)];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 1),
|
||||
child: Text(e.key, style: TextStyle(fontSize: fontSize, fontWeight: fontSize > 18 ? FontWeight.w700 : FontWeight.w500, color: c, height: 1.3)),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
// ─── 通用卡片 ────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildCard({required String title, required Widget child}) {
|
||||
|
||||
@@ -46,6 +46,10 @@ class UserPrefs {
|
||||
/// 主题模式: 0=跟随系统, 1=浅色, 2=深色
|
||||
int get themeMode => prefs.getInt('themeMode') ?? 0;
|
||||
Future<bool> setThemeMode(int value) => prefs.setInt('themeMode', value);
|
||||
|
||||
/// 上映日期:显示到日(true)/ 显示到月(false)
|
||||
bool get showExactReleaseDate => prefs.getBool('showExactReleaseDate') ?? true;
|
||||
Future<bool> setShowExactReleaseDate(bool value) => prefs.setBool('showExactReleaseDate', value);
|
||||
|
||||
/// 是否首次启动
|
||||
bool get isFirstLaunch => prefs.getBool('isFirstLaunch') ?? true;
|
||||
|
||||
@@ -125,27 +125,6 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
_buildProfileStatRow(Icons.menu_book_outlined, bookCount, '阅读'),
|
||||
const SizedBox(height: 12),
|
||||
_buildProfileStatRow(Icons.note_outlined, noteCount, '笔记'),
|
||||
const SizedBox(height: 14),
|
||||
Divider(height: 1, color: colors.outlineVariant),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsPage()));
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.settings_outlined, size: 16, color: colors.onSurface.withValues(alpha: 0.4)),
|
||||
const SizedBox(width: 8),
|
||||
Text('设置', style: TextStyle(fontSize: 13, color: colors.onSurface.withValues(alpha: 0.5))),
|
||||
const Spacer(),
|
||||
Icon(Icons.chevron_right, size: 14, color: colors.onSurface.withValues(alpha: 0.2)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user