generated from dellevin/template
适配深色模式
This commit is contained in:
@@ -55,6 +55,7 @@ class _AnimatedStarRatingState extends State<AnimatedStarRating>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final starValue = widget.rating / 2;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -84,7 +85,7 @@ class _AnimatedStarRatingState extends State<AnimatedStarRating>
|
||||
style: TextStyle(
|
||||
fontSize: widget.starSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: const Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -15,10 +15,11 @@ class AppRefreshIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return RefreshIndicator(
|
||||
onRefresh: onRefresh,
|
||||
color: const Color(0xFF1A1A1A),
|
||||
backgroundColor: Colors.white,
|
||||
color: colors.primary,
|
||||
backgroundColor: colors.surface,
|
||||
strokeWidth: 2.5,
|
||||
displacement: 60,
|
||||
semanticsLabel: semanticsLabel,
|
||||
|
||||
@@ -15,6 +15,7 @@ class BookListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/book-detail', arguments: book);
|
||||
@@ -23,28 +24,21 @@ class BookListItem extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 封面
|
||||
Expanded(
|
||||
child: _buildCover(),
|
||||
child: _buildCover(colors),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 书名
|
||||
Text(
|
||||
book.title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: colors.onSurface,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// 评分
|
||||
if (book.rating != null)
|
||||
AnimatedStarRating(rating: book.rating!, starSize: 12, showNumber: true)
|
||||
else
|
||||
@@ -53,45 +47,45 @@ class BookListItem extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建封面
|
||||
Widget _buildCover() {
|
||||
|
||||
Widget _buildCover(ColorScheme colors) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: const Color(0xFFE5E5E5), width: 0.5),
|
||||
border: Border.all(color: colors.outline, width: 0.5),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: FadeInLocalImage(
|
||||
path: book.coverPath,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: const Center(child: Icon(Icons.menu_book_outlined, size: 32, color: Color(0xFFCCCCCC))),
|
||||
errorWidget: const Center(child: Icon(Icons.menu_book_outlined, size: 32, color: Color(0xFFCCCCCC))),
|
||||
placeholder: Center(child: Icon(Icons.menu_book_outlined, size: 32, color: colors.onSurface.withValues(alpha: 0.25))),
|
||||
errorWidget: Center(child: Icon(Icons.menu_book_outlined, size: 32, color: colors.onSurface.withValues(alpha: 0.25))),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示删除确认对话框
|
||||
void _showDeleteDialog(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: colors.surface,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: const Text(
|
||||
title: Text(
|
||||
'确认删除',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
'确定要删除《${book.title}》吗?删除后可在回收站恢复。',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
@@ -99,7 +93,7 @@ class BookListItem extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF666666),
|
||||
foregroundColor: colors.onSurface.withValues(alpha: 0.6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
),
|
||||
child: const Text('取消'),
|
||||
@@ -111,8 +105,8 @@ class BookListItem extends StatelessWidget {
|
||||
ToastUtil.show(context, '已删除');
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: colors.error,
|
||||
foregroundColor: colors.onError,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
|
||||
@@ -8,20 +8,21 @@ class BookStatusBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
bottom: BorderSide(color: colors.outline, width: 0.5),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
@@ -42,7 +43,7 @@ class BookStatusBar extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A1A1A),
|
||||
color: colors.primary,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
@@ -58,18 +59,21 @@ class BookStatusBar extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
_buildTab(
|
||||
colors: colors,
|
||||
label: '已读',
|
||||
icon: Icons.check_circle_outline,
|
||||
isSelected: provider.bookStatusIndex == 0,
|
||||
onTap: () => provider.setBookStatusIndex(0),
|
||||
),
|
||||
_buildTab(
|
||||
colors: colors,
|
||||
label: '在读',
|
||||
icon: Icons.menu_book_outlined,
|
||||
isSelected: provider.bookStatusIndex == 1,
|
||||
onTap: () => provider.setBookStatusIndex(1),
|
||||
),
|
||||
_buildTab(
|
||||
colors: colors,
|
||||
label: '想读',
|
||||
icon: Icons.bookmark_outlined,
|
||||
isSelected: provider.bookStatusIndex == 2,
|
||||
@@ -89,6 +93,7 @@ class BookStatusBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildTab({
|
||||
required ColorScheme colors,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
required bool isSelected,
|
||||
@@ -108,7 +113,7 @@ class BookStatusBar extends StatelessWidget {
|
||||
Icon(
|
||||
icon,
|
||||
size: 16,
|
||||
color: isSelected ? Colors.white : const Color(0xFF666666),
|
||||
color: isSelected ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
@@ -116,7 +121,7 @@ class BookStatusBar extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
|
||||
color: isSelected ? Colors.white : const Color(0xFF666666),
|
||||
color: isSelected ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -8,34 +8,33 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 获取底部安全区域高度
|
||||
final bottomPadding = MediaQuery.of(context).padding.bottom;
|
||||
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
// 高度:导航栏本身高度 + 底部安全距离 + 上下边距
|
||||
height: 64 + bottomPadding + 16,
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Dock栏主体 - 悬浮效果
|
||||
Container(
|
||||
height: 56,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 40),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
color: Colors.black.withOpacity(isDark ? 0.3 : 0.08),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 4),
|
||||
spreadRadius: 0,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
color: Colors.black.withOpacity(isDark ? 0.15 : 0.04),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
spreadRadius: -2,
|
||||
@@ -45,19 +44,16 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// 主页按钮
|
||||
_buildNavItem(
|
||||
colors: colors,
|
||||
icon: Icons.home_outlined,
|
||||
activeIcon: Icons.home,
|
||||
isActive: provider.bottomNavIndex == 0,
|
||||
onTap: () => provider.setBottomNavIndex(0),
|
||||
),
|
||||
|
||||
// 中间新增按钮
|
||||
_buildAddButton(context, provider),
|
||||
|
||||
// 我的按钮
|
||||
_buildNavItem(
|
||||
colors: colors,
|
||||
icon: Icons.person_outline,
|
||||
activeIcon: Icons.person,
|
||||
isActive: provider.bottomNavIndex == 2,
|
||||
@@ -66,7 +62,6 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// 底部安全距离占位
|
||||
SizedBox(height: bottomPadding + 8),
|
||||
],
|
||||
),
|
||||
@@ -74,9 +69,9 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建导航项
|
||||
|
||||
Widget _buildNavItem({
|
||||
required ColorScheme colors,
|
||||
required IconData icon,
|
||||
required IconData activeIcon,
|
||||
required bool isActive,
|
||||
@@ -92,16 +87,16 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
child: Center(
|
||||
child: Icon(
|
||||
isActive ? activeIcon : icon,
|
||||
color: isActive ? const Color(0xFF1A1A1A) : const Color(0xFF999999),
|
||||
color: isActive ? colors.primary : colors.onSurface.withValues(alpha: 0.4),
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建中间新增按钮
|
||||
|
||||
Widget _buildAddButton(BuildContext context, AppProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return GestureDetector(
|
||||
onTap: () => _showAddDialog(context, provider),
|
||||
onLongPress: () => _showQuickAddDialog(context, provider),
|
||||
@@ -109,25 +104,23 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A1A1A),
|
||||
color: colors.primary,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
color: colors.onPrimary,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 长按快速添加 - 根据当前界面直接跳转到对应添加界面
|
||||
void _showQuickAddDialog(BuildContext context, AppProvider provider) {
|
||||
// 根据当前主标签页决定跳转到哪个添加界面
|
||||
final currentTab = provider.mainTabIndex;
|
||||
|
||||
|
||||
switch (currentTab) {
|
||||
case 0: // 观影标签页
|
||||
case 0:
|
||||
final statusMap = {
|
||||
0: 'watched',
|
||||
1: 'watching',
|
||||
@@ -140,7 +133,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
arguments: {'initialStatus': currentStatus},
|
||||
);
|
||||
break;
|
||||
case 1: // 阅读标签页
|
||||
case 1:
|
||||
final statusMap = {
|
||||
0: 'read',
|
||||
1: 'reading',
|
||||
@@ -153,7 +146,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
arguments: {'initialStatus': currentStatus},
|
||||
);
|
||||
break;
|
||||
case 2: // 笔记标签页
|
||||
case 2:
|
||||
Navigator.pushNamed(context, '/note-form');
|
||||
break;
|
||||
default:
|
||||
@@ -161,34 +154,33 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示新增对话框
|
||||
void _showAddDialog(BuildContext context, AppProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: colors.surface,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (BuildContext context) {
|
||||
final bottomColors = Theme.of(context).colorScheme;
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 顶部指示条
|
||||
Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE0E0E0),
|
||||
color: bottomColors.onSurface.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// 标题
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
@@ -196,15 +188,15 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: bottomColors.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// 选项列表
|
||||
_buildAddOption(
|
||||
colors: bottomColors,
|
||||
icon: Icons.movie_outlined,
|
||||
title: '添加观影',
|
||||
subtitle: '记录你看过的电影',
|
||||
@@ -224,6 +216,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
_buildAddOption(
|
||||
colors: bottomColors,
|
||||
icon: Icons.menu_book_outlined,
|
||||
title: '添加阅读',
|
||||
subtitle: '记录你读过的书',
|
||||
@@ -243,6 +236,7 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
_buildAddOption(
|
||||
colors: bottomColors,
|
||||
icon: Icons.note_outlined,
|
||||
title: '添加笔记',
|
||||
subtitle: '记录你的想法和笔记',
|
||||
@@ -259,8 +253,8 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建新增选项
|
||||
Widget _buildAddOption({
|
||||
required ColorScheme colors,
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
@@ -276,13 +270,13 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 22,
|
||||
color: const Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
@@ -292,26 +286,26 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: Color(0xFFCCCCCC),
|
||||
color: colors.onSurface.withValues(alpha: 0.25),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -33,36 +33,25 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Drawer(
|
||||
backgroundColor: const Color(0xFFF8F8F8),
|
||||
backgroundColor: colors.surfaceContainerHigh,
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 头像 + 统计(独立卡片区域)
|
||||
_buildProfileCard(context),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 热力图
|
||||
_buildCalendarSection(context),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 最近添加
|
||||
_buildRecentSection(context),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 功能入口
|
||||
_buildToolsCard(context),
|
||||
|
||||
// 底部版本号
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 32),
|
||||
child: Center(
|
||||
child: Text('v$_version', style: const TextStyle(fontSize: 11, color: Color(0xFFD0D0D0))),
|
||||
child: Text('v$_version', style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.2))),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -77,6 +66,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
Widget _buildProfileCard(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final userPrefs = UserPrefs();
|
||||
final nickname = userPrefs.nickname;
|
||||
final motto = userPrefs.motto;
|
||||
@@ -89,77 +79,69 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
margin: const EdgeInsets.fromLTRB(16, 16, 16, 0),
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 头像 + 名称/座右铭 + 统计
|
||||
Row(
|
||||
children: [
|
||||
// 头像
|
||||
Container(
|
||||
width: 52,
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: const Color(0xFFF5F5F5),
|
||||
border: Border.all(color: const Color(0xFFEEEEEE), width: 0.5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
border: Border.all(color: colors.outlineVariant, width: 0.5),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: avatarPath != null && avatarPath.isNotEmpty
|
||||
? Image.file(File(avatarPath), fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) =>
|
||||
const Icon(Icons.person_outline, size: 26, color: Color(0xFFBBBBBB)))
|
||||
: const Icon(Icons.person_outline, size: 26, color: Color(0xFFBBBBBB)),
|
||||
Icon(Icons.person_outline, size: 26, color: colors.onSurface.withValues(alpha: 0.3)))
|
||||
: Icon(Icons.person_outline, size: 26, color: colors.onSurface.withValues(alpha: 0.3)),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
// 名称 + 座右铭
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(nickname, style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A))),
|
||||
Text(nickname, style: TextStyle(fontSize: 17, fontWeight: FontWeight.w600, color: colors.onSurface)),
|
||||
const SizedBox(height: 2),
|
||||
Text(motto, maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 12, color: Color(0xFFAAAAAA))),
|
||||
style: TextStyle(fontSize: 12, color: colors.onSurface.withValues(alpha: 0.35))),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
const Divider(height: 1, color: Color(0xFFF0F0F0)),
|
||||
Divider(height: 1, color: colors.outlineVariant),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
// 统计数字
|
||||
_buildProfileStatRow(Icons.movie_outlined, movieCount, '观影'),
|
||||
const SizedBox(height: 12),
|
||||
_buildProfileStatRow(Icons.menu_book_outlined, bookCount, '阅读'),
|
||||
const SizedBox(height: 12),
|
||||
_buildProfileStatRow(Icons.note_outlined, noteCount, '笔记'),
|
||||
|
||||
// 设置入口
|
||||
const SizedBox(height: 14),
|
||||
const Divider(height: 1, color: Color(0xFFF0F0F0)),
|
||||
Divider(height: 1, color: colors.outlineVariant),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsPage()));
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(top: 14),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.settings_outlined, size: 16, color: Color(0xFF999999)),
|
||||
SizedBox(width: 8),
|
||||
Text('设置', style: TextStyle(fontSize: 13, color: Color(0xFF888888))),
|
||||
Spacer(),
|
||||
Icon(Icons.chevron_right, size: 14, color: Color(0xFFD0D0D0)),
|
||||
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)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -172,13 +154,14 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
}
|
||||
|
||||
Widget _buildProfileStatRow(IconData icon, int count, String label) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 16, color: const Color(0xFF888888)),
|
||||
Icon(icon, size: 16, color: colors.onSurface.withValues(alpha: 0.5)),
|
||||
const SizedBox(width: 10),
|
||||
Text(label, style: const TextStyle(fontSize: 13, color: Color(0xFF888888))),
|
||||
Text(label, style: TextStyle(fontSize: 13, color: colors.onSurface.withValues(alpha: 0.5))),
|
||||
const Spacer(),
|
||||
Text(_formatCount(count), style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A))),
|
||||
Text(_formatCount(count), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface)),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -192,10 +175,11 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
// ─── 功能入口卡片 ────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildToolsCard(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
@@ -204,12 +188,12 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const StrollPage()));
|
||||
}, topRounded: true),
|
||||
const Divider(height: 1, indent: 52, endIndent: 20, color: Color(0xFFF0F0F0)),
|
||||
Divider(height: 1, indent: 52, endIndent: 20, color: colors.outlineVariant),
|
||||
_buildToolItem(Icons.label_outline, '标签管理', () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const TagManagementPage()));
|
||||
}),
|
||||
const Divider(height: 1, indent: 52, endIndent: 20, color: Color(0xFFF0F0F0)),
|
||||
Divider(height: 1, indent: 52, endIndent: 20, color: colors.outlineVariant),
|
||||
_buildToolItem(Icons.description_outlined, 'MD阅读', () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const MdReaderTabPage()));
|
||||
@@ -220,6 +204,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
}
|
||||
|
||||
Widget _buildToolItem(IconData icon, String title, VoidCallback onTap, {bool topRounded = false, bool bottomRounded = false}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.only(
|
||||
@@ -232,21 +217,22 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: const Color(0xFF555555)),
|
||||
Icon(icon, size: 20, color: colors.onSurface.withValues(alpha: 0.7)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Text(title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFF1A1A1A)))),
|
||||
const Icon(Icons.chevron_right, size: 16, color: Color(0xFFD0D0D0)),
|
||||
Expanded(child: Text(title, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onSurface))),
|
||||
Icon(Icons.chevron_right, size: 16, color: colors.onSurface.withValues(alpha: 0.2)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ─── 热力图(保持现状) ──────────────────────────────────────────────
|
||||
// ─── 热力图 ──────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildCalendarSection(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final Map<DateTime, int> dailyCounts = {};
|
||||
for (final movie in provider.movies.where((m) => !m.isDeleted)) {
|
||||
final date = DateTime(movie.createdAt.year, movie.createdAt.month, movie.createdAt.day);
|
||||
@@ -299,15 +285,15 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(16)),
|
||||
decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(16)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Row(
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.calendar_today, size: 14, color: Color(0xFF999999)),
|
||||
SizedBox(width: 8),
|
||||
Text('热力图', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: Color(0xFF666666))),
|
||||
Icon(Icons.calendar_today, size: 14, color: colors.onSurface.withValues(alpha: 0.4)),
|
||||
const SizedBox(width: 8),
|
||||
Text('热力图', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
@@ -324,7 +310,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
final label = keepWeeks.contains(week) ? monthLabels[week] : null;
|
||||
return SizedBox(
|
||||
width: cellSize + cellGap,
|
||||
child: label != null ? Text(label, style: const TextStyle(fontSize: 9, color: Color(0xFFBBBBBB))) : null,
|
||||
child: label != null ? Text(label, style: TextStyle(fontSize: 9, color: colors.onSurface.withValues(alpha: 0.3))) : null,
|
||||
);
|
||||
}),
|
||||
),
|
||||
@@ -347,7 +333,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
const Text('少', style: TextStyle(fontSize: 9, color: Color(0xFFBBBBBB))),
|
||||
Text('少', style: TextStyle(fontSize: 9, color: colors.onSurface.withValues(alpha: 0.3))),
|
||||
const SizedBox(width: 3),
|
||||
_legendCell(const Color(0xFFF0F0F0)),
|
||||
_legendCell(const Color(0xFFC8E6C9)),
|
||||
@@ -355,7 +341,7 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
_legendCell(const Color(0xFF2E7D32)),
|
||||
_legendCell(const Color(0xFF1B5E20)),
|
||||
const SizedBox(width: 3),
|
||||
const Text('多', style: TextStyle(fontSize: 9, color: Color(0xFFBBBBBB))),
|
||||
Text('多', style: TextStyle(fontSize: 9, color: colors.onSurface.withValues(alpha: 0.3))),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -384,21 +370,22 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
Widget _buildRecentSection(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final recent = _getRecentItems(provider);
|
||||
if (recent.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(16)),
|
||||
decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(16)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Row(
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.schedule, size: 14, color: Color(0xFF999999)),
|
||||
SizedBox(width: 8),
|
||||
Text('最近添加', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: Color(0xFF666666))),
|
||||
Icon(Icons.schedule, size: 14, color: colors.onSurface.withValues(alpha: 0.4)),
|
||||
const SizedBox(width: 8),
|
||||
Text('最近添加', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
@@ -408,15 +395,15 @@ class _CustomDrawerState extends State<CustomDrawer> {
|
||||
children: [
|
||||
Icon(
|
||||
item.type == 'movie' ? Icons.movie_outlined : item.type == 'book' ? Icons.menu_book_outlined : Icons.note_outlined,
|
||||
size: 14, color: const Color(0xFFBBBBBB),
|
||||
size: 14, color: colors.onSurface.withValues(alpha: 0.3),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(item.title, maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF444444))),
|
||||
style: TextStyle(fontSize: 13, color: colors.onSurface.withValues(alpha: 0.75))),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(_recentTimeAgo(item.date), style: const TextStyle(fontSize: 10, color: Color(0xFFCCCCCC))),
|
||||
Text(_recentTimeAgo(item.date), style: TextStyle(fontSize: 10, color: colors.onSurface.withValues(alpha: 0.25))),
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
||||
@@ -51,7 +51,6 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是 http 开头,直接当网络图片
|
||||
if (widget.path!.startsWith('http')) {
|
||||
_useNetwork = true;
|
||||
_imageUrl = widget.path;
|
||||
@@ -60,7 +59,6 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
return;
|
||||
}
|
||||
|
||||
// 本地文件存在就直接显示
|
||||
final file = File(widget.path!);
|
||||
if (file.existsSync()) {
|
||||
setState(() => _loaded = true);
|
||||
@@ -68,7 +66,6 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
return;
|
||||
}
|
||||
|
||||
// 本地不存在,尝试服务端 URL
|
||||
if (ServerDataService.isActive) {
|
||||
try {
|
||||
final url = await ServerDataService.toImageUrl(widget.path!);
|
||||
@@ -105,13 +102,14 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
if (_error) {
|
||||
return widget.errorWidget ??
|
||||
Container(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
color: const Color(0xFFF5F5F5),
|
||||
child: const Icon(Icons.broken_image_outlined, size: 24, color: Color(0xFFCCCCCC)),
|
||||
color: colors.surfaceContainerHighest,
|
||||
child: Icon(Icons.broken_image_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
);
|
||||
}
|
||||
if (!_loaded) {
|
||||
@@ -119,7 +117,7 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
Container(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
);
|
||||
}
|
||||
return FadeTransition(
|
||||
@@ -136,8 +134,8 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
Container(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
color: const Color(0xFFF5F5F5),
|
||||
child: const Icon(Icons.broken_image_outlined, size: 24, color: Color(0xFFCCCCCC)),
|
||||
color: colors.surfaceContainerHighest,
|
||||
child: Icon(Icons.broken_image_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
);
|
||||
},
|
||||
)
|
||||
@@ -150,8 +148,8 @@ class _FadeInLocalImageState extends State<FadeInLocalImage>
|
||||
Container(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
color: const Color(0xFFF5F5F5),
|
||||
child: const Icon(Icons.broken_image_outlined, size: 24, color: Color(0xFFCCCCCC)),
|
||||
color: colors.surfaceContainerHighest,
|
||||
child: Icon(Icons.broken_image_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ class MovieListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/movie-detail', arguments: movie);
|
||||
@@ -23,28 +24,21 @@ class MovieListItem extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 海报
|
||||
Expanded(
|
||||
child: _buildPoster(),
|
||||
child: _buildPoster(colors),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 影视名称
|
||||
Text(
|
||||
movie.title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// 评分
|
||||
if (movie.rating != null)
|
||||
AnimatedStarRating(rating: movie.rating!, starSize: 12, showNumber: true)
|
||||
else
|
||||
@@ -53,45 +47,45 @@ class MovieListItem extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建海报
|
||||
Widget _buildPoster() {
|
||||
|
||||
Widget _buildPoster(ColorScheme colors) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: const Color(0xFFE5E5E5), width: 0.5),
|
||||
border: Border.all(color: colors.outline, width: 0.5),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: FadeInLocalImage(
|
||||
path: movie.posterPath,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: const Center(child: Icon(Icons.movie_outlined, size: 24, color: Color(0xFFCCCCCC))),
|
||||
errorWidget: const Center(child: Icon(Icons.movie_outlined, size: 24, color: Color(0xFFCCCCCC))),
|
||||
placeholder: Center(child: Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25))),
|
||||
errorWidget: Center(child: Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25))),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示删除确认对话框
|
||||
|
||||
void _showDeleteDialog(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: colors.surface,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: const Text(
|
||||
title: Text(
|
||||
'确认删除',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
'确定要删除《${movie.title}》吗?删除后可在回收站恢复。',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
@@ -99,7 +93,7 @@ class MovieListItem extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF666666),
|
||||
foregroundColor: colors.onSurface.withValues(alpha: 0.6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
),
|
||||
child: const Text('取消'),
|
||||
@@ -111,8 +105,8 @@ class MovieListItem extends StatelessWidget {
|
||||
ToastUtil.show(context, '已删除');
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: colors.error,
|
||||
foregroundColor: colors.onError,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
|
||||
@@ -8,20 +8,21 @@ class MovieStatusBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
bottom: BorderSide(color: colors.outline, width: 0.5),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
@@ -42,7 +43,7 @@ class MovieStatusBar extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1A1A1A),
|
||||
color: colors.primary,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
@@ -58,18 +59,21 @@ class MovieStatusBar extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
_buildTab(
|
||||
colors: colors,
|
||||
label: '已看',
|
||||
icon: Icons.check_circle_outline,
|
||||
isSelected: provider.movieStatusIndex == 0,
|
||||
onTap: () => provider.setMovieStatusIndex(0),
|
||||
),
|
||||
_buildTab(
|
||||
colors: colors,
|
||||
label: '在看',
|
||||
icon: Icons.play_circle_outline,
|
||||
isSelected: provider.movieStatusIndex == 1,
|
||||
onTap: () => provider.setMovieStatusIndex(1),
|
||||
),
|
||||
_buildTab(
|
||||
colors: colors,
|
||||
label: '想看',
|
||||
icon: Icons.bookmark_outline,
|
||||
isSelected: provider.movieStatusIndex == 2,
|
||||
@@ -89,6 +93,7 @@ class MovieStatusBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildTab({
|
||||
required ColorScheme colors,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
required bool isSelected,
|
||||
@@ -108,7 +113,7 @@ class MovieStatusBar extends StatelessWidget {
|
||||
Icon(
|
||||
icon,
|
||||
size: 16,
|
||||
color: isSelected ? Colors.white : const Color(0xFF666666),
|
||||
color: isSelected ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
@@ -116,7 +121,7 @@ class MovieStatusBar extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
|
||||
color: isSelected ? Colors.white : const Color(0xFF666666),
|
||||
color: isSelected ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -14,14 +14,12 @@ class NoteListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 使用 RepaintBoundary 减少重绘
|
||||
return RepaintBoundary(
|
||||
child: _NoteListItemContent(note: note),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 笔记列表项内容 - 分离出来便于优化
|
||||
class _NoteListItemContent extends StatelessWidget {
|
||||
final Note note;
|
||||
|
||||
@@ -29,10 +27,10 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/note-detail', arguments: note).then((_) async {
|
||||
// 返回时刷新笔记列表
|
||||
await context.read<AppProvider>().loadNotes();
|
||||
});
|
||||
},
|
||||
@@ -41,40 +39,37 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFAFAFA),
|
||||
color: colors.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
|
||||
border: Border.all(color: colors.outlineVariant, width: 0.5),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 顶部:时间 + MD标记
|
||||
Row(
|
||||
children: [
|
||||
// 时间
|
||||
Text(
|
||||
_formatDateCached(note.updatedAt),
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF999999),
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// MD标记
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
|
||||
border: Border.all(color: colors.outlineVariant, width: 0.5),
|
||||
),
|
||||
child: const Text(
|
||||
child: Text(
|
||||
'MD',
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF999999),
|
||||
color: colors.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -83,14 +78,13 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
|
||||
const SizedBox(height: 6),
|
||||
|
||||
// 标题
|
||||
if (note.title.isNotEmpty) ...[
|
||||
Text(
|
||||
note.title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
color: colors.onSurface,
|
||||
height: 1.4,
|
||||
),
|
||||
maxLines: 1,
|
||||
@@ -99,20 +93,18 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
|
||||
// 内容摘要(去除Markdown标记),内容为空则不显示
|
||||
if (_collapseBlankLines(_cleanMarkdown(note.content).trim()).isNotEmpty)
|
||||
Text(
|
||||
_collapseBlankLines(_cleanMarkdown(note.content).trim()),
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
height: 1.5,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
// 底部标签
|
||||
if (note.tags.isNotEmpty) ...[
|
||||
const SizedBox(height: 6),
|
||||
Wrap(
|
||||
@@ -122,15 +114,15 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
|
||||
border: Border.all(color: colors.outlineVariant, width: 0.5),
|
||||
),
|
||||
child: Text(
|
||||
tag,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -138,10 +130,9 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
|
||||
// 图片预览
|
||||
if (note.images.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
_buildImagePreviewRow(),
|
||||
_buildImagePreviewRow(colors),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -149,8 +140,7 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 图片预览行
|
||||
Widget _buildImagePreviewRow() {
|
||||
Widget _buildImagePreviewRow(ColorScheme colors) {
|
||||
final images = note.images;
|
||||
final count = images.length.clamp(0, 3);
|
||||
return Row(
|
||||
@@ -162,14 +152,14 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(right: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
|
||||
border: Border.all(color: colors.outlineVariant, width: 0.5),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: FadeInLocalImage(
|
||||
path: images[i],
|
||||
fit: BoxFit.cover,
|
||||
errorWidget: Container(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -178,13 +168,13 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
color: colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'+${images.length - 3}',
|
||||
style: const TextStyle(fontSize: 12, color: Color(0xFF999999), fontWeight: FontWeight.w500),
|
||||
style: TextStyle(fontSize: 12, color: colors.onSurface.withValues(alpha: 0.4), fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -192,45 +182,44 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 清理 Markdown 标记,提取纯文本
|
||||
String _cleanMarkdown(String text) {
|
||||
return text
|
||||
.replaceAll(RegExp(r'^#+\s+', multiLine: true), '') // 标题
|
||||
.replaceAll(RegExp(r'\*\*(.+?)\*\*'), r'$1') // 粗体
|
||||
.replaceAll(RegExp(r'\*(.+?)\*'), r'$1') // 斜体
|
||||
.replaceAll(RegExp(r'`(.+?)`'), r'$1') // 行内代码
|
||||
.replaceAll(RegExp(r'^\s*[-*+]\s', multiLine: true), '') // 列表
|
||||
.replaceAll(RegExp(r'^\s*>\s', multiLine: true), '') // 引用
|
||||
.replaceAll(RegExp(r'\[([^\]]+)\]\([^)]+\)'), r'$1') // 链接
|
||||
.replaceAll(RegExp(r'!\[([^\]]*)\]\([^)]+\)'), '') // 图片
|
||||
.replaceAll(RegExp(r'^#+\s+', multiLine: true), '')
|
||||
.replaceAll(RegExp(r'\*\*(.+?)\*\*'), r'$1')
|
||||
.replaceAll(RegExp(r'\*(.+?)\*'), r'$1')
|
||||
.replaceAll(RegExp(r'`(.+?)`'), r'$1')
|
||||
.replaceAll(RegExp(r'^\s*[-*+]\s', multiLine: true), '')
|
||||
.replaceAll(RegExp(r'^\s*>\s', multiLine: true), '')
|
||||
.replaceAll(RegExp(r'\[([^\]]+)\]\([^)]+\)'), r'$1')
|
||||
.replaceAll(RegExp(r'!\[([^\]]*)\]\([^)]+\)'), '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
/// 合并连续空行为单行
|
||||
String _collapseBlankLines(String text) {
|
||||
return text.replaceAll(RegExp(r'\n\s*\n+'), '\n');
|
||||
}
|
||||
|
||||
/// 显示删除确认对话框
|
||||
void _showDeleteDialog(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: colors.surface,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: const Text(
|
||||
title: Text(
|
||||
'确认删除',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colors.onSurface,
|
||||
),
|
||||
),
|
||||
content: const Text(
|
||||
content: Text(
|
||||
'确定要删除这条笔记吗?删除后可在回收站恢复。',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
color: colors.onSurface.withValues(alpha: 0.6),
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
@@ -238,7 +227,7 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF666666),
|
||||
foregroundColor: colors.onSurface.withValues(alpha: 0.6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
),
|
||||
child: const Text('取消'),
|
||||
@@ -250,8 +239,8 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
ToastUtil.show(context, '已删除');
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: colors.error,
|
||||
foregroundColor: colors.onError,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -267,28 +256,24 @@ class _NoteListItemContent extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
// 日期格式化缓存
|
||||
final Map<DateTime, String> _dateFormatCache = {};
|
||||
|
||||
/// 格式化日期(带缓存)
|
||||
String _formatDateCached(DateTime date) {
|
||||
// 使用日期部分作为缓存键(忽略时分秒)
|
||||
final cacheKey = DateTime(date.year, date.month, date.day);
|
||||
|
||||
|
||||
if (_dateFormatCache.containsKey(cacheKey)) {
|
||||
return _dateFormatCache[cacheKey]!;
|
||||
}
|
||||
|
||||
|
||||
final result = _formatDate(date);
|
||||
_dateFormatCache[cacheKey] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 格式化日期
|
||||
String _formatDate(DateTime date) {
|
||||
final now = DateTime.now();
|
||||
final difference = now.difference(date);
|
||||
|
||||
|
||||
if (difference.inDays == 0) {
|
||||
if (difference.inHours == 0) {
|
||||
if (difference.inMinutes == 0) {
|
||||
|
||||
@@ -42,6 +42,7 @@ class _ShimmerSkeletonState extends State<ShimmerSkeleton>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (context, child) {
|
||||
@@ -49,7 +50,7 @@ class _ShimmerSkeletonState extends State<ShimmerSkeleton>
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE0E0E0).withValues(alpha: _animation.value),
|
||||
color: colors.surfaceContainerHighest.withValues(alpha: _animation.value),
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
),
|
||||
);
|
||||
@@ -134,6 +135,7 @@ class NoteSkeletonList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 100),
|
||||
itemCount: 6,
|
||||
@@ -141,7 +143,7 @@ class NoteSkeletonList extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF8F8F8),
|
||||
color: colors.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Column(
|
||||
|
||||
Reference in New Issue
Block a user