generated from dellevin/template
自定义昵称和头像
This commit is contained in:
@@ -17,12 +17,8 @@ class CustomBottomNavBar extends StatelessWidget {
|
||||
// 新增按钮 - 显示选择对话框
|
||||
_showAddDialog(context, provider);
|
||||
} else {
|
||||
// 切换主页/我的页面
|
||||
provider.setBottomNavIndex(index);
|
||||
if (index == 0) {
|
||||
// 主页 - 重置到首页
|
||||
provider.setMainTabIndex(0);
|
||||
}
|
||||
// index == 2 是我的页面(待实现)
|
||||
}
|
||||
},
|
||||
type: BottomNavigationBarType.fixed,
|
||||
|
||||
@@ -1,51 +1,55 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../utils/user_prefs.dart';
|
||||
|
||||
/// 自定义左侧弹出菜单
|
||||
/// 自定义左侧弹出菜单 - 极简主义设计
|
||||
class CustomDrawer extends StatelessWidget {
|
||||
const CustomDrawer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Drawer(
|
||||
backgroundColor: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
// 顶部用户信息区域(含热力图)
|
||||
// 顶部用户信息区域
|
||||
_buildHeader(context),
|
||||
|
||||
// 分割线
|
||||
Divider(height: 1, color: colorScheme.outlineVariant),
|
||||
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
|
||||
|
||||
// 菜单项列表
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.analytics),
|
||||
title: const Text('统计'),
|
||||
_buildMenuItem(
|
||||
icon: Icons.analytics_outlined,
|
||||
title: '统计',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// TODO: 跳转到统计页面
|
||||
_showToast(context, '统计功能开发中');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete_outline),
|
||||
title: const Text('回收站'),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.delete_outline,
|
||||
title: '回收站',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// TODO: 跳转到回收站页面
|
||||
_showToast(context, '回收站功能开发中');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: const Text('设置'),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.settings_outlined,
|
||||
title: '设置',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// TODO: 跳转到设置页面
|
||||
_showToast(context, '设置功能开发中');
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -54,12 +58,12 @@ class CustomDrawer extends StatelessWidget {
|
||||
|
||||
// 底部版本信息
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: const Text(
|
||||
'MookNote v1.0.0',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -68,146 +72,157 @@ class CustomDrawer extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建头部(含热力图)
|
||||
/// 构建头部
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
// 统计数据
|
||||
final movieCount = provider.movies.where((m) => !m.isDeleted).length;
|
||||
final bookCount = provider.books.length;
|
||||
final noteCount = provider.notes.length;
|
||||
|
||||
// 获取用户信息
|
||||
final userPrefs = UserPrefs();
|
||||
final nickname = userPrefs.nickname;
|
||||
final motto = userPrefs.motto;
|
||||
final avatarPath = userPrefs.avatarPath;
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(16, 48, 16, 16),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
Theme.of(context).colorScheme.surface,
|
||||
],
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.fromLTRB(24, 48, 24, 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 用户头像和名称
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 32,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
child: const Icon(
|
||||
Icons.person,
|
||||
color: Colors.white,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'用户',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
// 用户头像
|
||||
Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: const Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
child: avatarPath != null && avatarPath.isNotEmpty
|
||||
? ClipOval(
|
||||
child: Image.file(
|
||||
File(avatarPath),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildAvatarPlaceholder(),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'记录生活点滴',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: _buildAvatarPlaceholder(),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// GitHub 风格热力图
|
||||
_buildHeatmap(context),
|
||||
// 用户名称
|
||||
Text(
|
||||
nickname,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// 座右铭
|
||||
Text(
|
||||
motto,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 简化统计
|
||||
Row(
|
||||
children: [
|
||||
_buildStatItem('观影', movieCount),
|
||||
const SizedBox(width: 24),
|
||||
_buildStatItem('阅读', bookCount),
|
||||
const SizedBox(width: 24),
|
||||
_buildStatItem('笔记', noteCount),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvatarPlaceholder() {
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.person_outline,
|
||||
size: 32,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建热力图
|
||||
Widget _buildHeatmap(BuildContext context) {
|
||||
const int weeks = 52; // 一年 52 周
|
||||
const int daysPerWeek = 7;
|
||||
|
||||
// 生成随机数据(实际应从数据库获取)
|
||||
final random = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
/// 统计项
|
||||
Widget _buildStatItem(String label, int count) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'年度记录',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
'$count',
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: daysPerWeek * 14, // 每个格子 14x14
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List.generate(weeks, (weekIndex) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 2),
|
||||
child: Column(
|
||||
children: List.generate(daysPerWeek, (dayIndex) {
|
||||
// 根据随机值决定颜色深度
|
||||
final intensity = (random + weekIndex * 7 + dayIndex) % 100 / 100;
|
||||
final color = _getHeatmapColor(intensity, context);
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 2),
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Less',
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
Text(
|
||||
'More',
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 根据强度获取热力图颜色
|
||||
Color _getHeatmapColor(double intensity, BuildContext context) {
|
||||
if (intensity == 0) {
|
||||
return Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
} else if (intensity < 0.25) {
|
||||
return Theme.of(context).colorScheme.primaryContainer.withOpacity(0.4);
|
||||
} else if (intensity < 0.5) {
|
||||
return Theme.of(context).colorScheme.primaryContainer.withOpacity(0.6);
|
||||
} else if (intensity < 0.75) {
|
||||
return Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8);
|
||||
} else {
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
}
|
||||
/// 菜单项
|
||||
Widget _buildMenuItem({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: Icon(icon, size: 22, color: const Color(0xFF666666)),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 20,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示提示
|
||||
void _showToast(BuildContext context, String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
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/app_theme.dart';
|
||||
|
||||
/// 观影列表项组件
|
||||
/// 观影列表项 - 极简主义设计
|
||||
class MovieListItem extends StatelessWidget {
|
||||
final Movie movie;
|
||||
|
||||
@@ -13,309 +10,181 @@ class MovieListItem extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final colorScheme = theme.colorScheme;
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(
|
||||
color: colorScheme.outline.withOpacity(0.1),
|
||||
width: 1,
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pushNamed(context, '/movie-detail', arguments: movie),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, '/movie-detail', arguments: movie);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 海报
|
||||
_buildPoster(context),
|
||||
|
||||
const SizedBox(width: 14),
|
||||
|
||||
// 影片信息
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 海报
|
||||
_buildPoster(),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 信息
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题
|
||||
Text(
|
||||
movie.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
const SizedBox(height: 6),
|
||||
|
||||
// 年份和评分
|
||||
_buildMetaInfo(),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 导演
|
||||
if (movie.directors.isNotEmpty)
|
||||
Text(
|
||||
movie.title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colorScheme.onSurface,
|
||||
movie.directors.take(2).join(' / '),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
const SizedBox(height: 6),
|
||||
|
||||
// 上映日期和评分
|
||||
Row(
|
||||
children: [
|
||||
if (movie.releaseDate != null) ...[
|
||||
Icon(
|
||||
Icons.calendar_today_outlined,
|
||||
size: 13,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.7),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'${movie.releaseDate!.year}',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
|
||||
if (movie.rating != null) ...[
|
||||
Icon(
|
||||
Icons.star_rounded,
|
||||
size: 14,
|
||||
color: Colors.amber[700],
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
movie.rating!.toStringAsFixed(1),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.amber[700],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 导演
|
||||
if (movie.directors.isNotEmpty)
|
||||
_buildInfoRow(
|
||||
context,
|
||||
prefix: '导演',
|
||||
items: movie.directors.take(2).toList(),
|
||||
),
|
||||
|
||||
if (movie.directors.isNotEmpty && movie.genres.isNotEmpty)
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// 类型标签
|
||||
if (movie.genres.isNotEmpty)
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 4,
|
||||
children: movie.genres.take(3).map((genre) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
genre,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: colorScheme.primary.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 状态标签
|
||||
_buildStatusTag(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 右侧操作按钮
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.edit_outlined, size: 20, color: colorScheme.primary),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, '/movie-form', arguments: movie);
|
||||
},
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
IconButton(
|
||||
icon: Icon(Icons.delete_outline, size: 20, color: colorScheme.error.withOpacity(0.7)),
|
||||
onPressed: () => _showDeleteDialog(context, movie),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
|
||||
// 状态
|
||||
_buildStatusTag(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 箭头
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 20,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建海报
|
||||
Widget _buildPoster(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
width: 70,
|
||||
height: 100,
|
||||
color: colorScheme.surfaceContainerHighest,
|
||||
child: movie.posterPath != null && movie.posterPath!.isNotEmpty
|
||||
? Image.file(
|
||||
File(movie.posterPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) => _buildPlaceholder(context),
|
||||
)
|
||||
: _buildPlaceholder(context),
|
||||
/// 海报
|
||||
Widget _buildPoster() {
|
||||
return Container(
|
||||
width: 56,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE5E5E5),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: movie.posterPath != null && movie.posterPath!.isNotEmpty
|
||||
? Image.file(
|
||||
File(movie.posterPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildPlaceholder(),
|
||||
)
|
||||
: _buildPlaceholder(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaceholder(BuildContext context) {
|
||||
return Center(
|
||||
Widget _buildPlaceholder() {
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.movie_outlined,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.3),
|
||||
size: 28,
|
||||
size: 20,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建信息行
|
||||
Widget _buildInfoRow(BuildContext context, {required String prefix, required List<String> items}) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
/// 元信息
|
||||
Widget _buildMetaInfo() {
|
||||
final items = <String>[];
|
||||
|
||||
if (movie.releaseDate != null) {
|
||||
items.add('${movie.releaseDate!.year}');
|
||||
}
|
||||
if (movie.rating != null) {
|
||||
items.add(movie.rating!.toStringAsFixed(1));
|
||||
}
|
||||
|
||||
if (items.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
'$prefix: ',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
items.join(' / '),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.8),
|
||||
children: items.asMap().entries.map((entry) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
entry.value,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (entry.key < items.length - 1)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
'·',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建状态标签
|
||||
Widget _buildStatusTag(BuildContext context) {
|
||||
Color statusColor;
|
||||
String statusText;
|
||||
/// 状态标签
|
||||
Widget _buildStatusTag() {
|
||||
String label;
|
||||
Color color;
|
||||
|
||||
switch (movie.status) {
|
||||
case 'watched':
|
||||
statusColor = AppTheme.watchedColor;
|
||||
statusText = '已看';
|
||||
break;
|
||||
case 'want_to_watch':
|
||||
statusColor = AppTheme.wantToWatchColor;
|
||||
statusText = '想看';
|
||||
label = '已看';
|
||||
color = const Color(0xFF1A1A1A);
|
||||
break;
|
||||
case 'watching':
|
||||
statusColor = AppTheme.watchingColor;
|
||||
statusText = '在看';
|
||||
label = '在看';
|
||||
color = const Color(0xFF666666);
|
||||
break;
|
||||
case 'want_to_watch':
|
||||
label = '想看';
|
||||
color = const Color(0xFF999999);
|
||||
break;
|
||||
default:
|
||||
statusColor = Colors.grey;
|
||||
statusText = '未知';
|
||||
label = '未知';
|
||||
color = const Color(0xFFCCCCCC);
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: statusColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: statusColor.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
statusText,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: statusColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示删除对话框
|
||||
void _showDeleteDialog(BuildContext context, Movie movie) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: Text(
|
||||
'确认删除',
|
||||
style: TextStyle(color: colorScheme.onSurface),
|
||||
),
|
||||
content: Text(
|
||||
'确定要删除"${movie.title}"吗?',
|
||||
style: TextStyle(color: colorScheme.onSurface.withOpacity(0.7)),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await context.read<AppProvider>().removeMovie(movie.id);
|
||||
if (!context.mounted) return;
|
||||
Navigator.pop(context);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text('已删除'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: colorScheme.primary,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(color: colorScheme.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
return Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../utils/app_theme.dart';
|
||||
|
||||
/// 观影状态选择栏
|
||||
/// 观影状态选择栏 - 极简主义设计
|
||||
class MovieStatusBar extends StatelessWidget {
|
||||
const MovieStatusBar({super.key});
|
||||
|
||||
@@ -12,44 +11,26 @@ class MovieStatusBar extends StatelessWidget {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
_buildStatusItem(
|
||||
context,
|
||||
'已看',
|
||||
AppTheme.watchedColor,
|
||||
Icons.check_circle,
|
||||
0,
|
||||
provider.movieStatusIndex,
|
||||
() => provider.setMovieStatusIndex(0),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const SizedBox(width: 24),
|
||||
_buildStatusItem(
|
||||
context,
|
||||
'想看',
|
||||
AppTheme.wantToWatchColor,
|
||||
Icons.bookmark_border,
|
||||
1,
|
||||
provider.movieStatusIndex,
|
||||
() => provider.setMovieStatusIndex(1),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const SizedBox(width: 24),
|
||||
_buildStatusItem(
|
||||
context,
|
||||
'在看',
|
||||
AppTheme.watchingColor,
|
||||
Icons.play_circle_outline,
|
||||
2,
|
||||
provider.movieStatusIndex,
|
||||
() => provider.setMovieStatusIndex(2),
|
||||
@@ -63,49 +44,21 @@ class MovieStatusBar extends StatelessWidget {
|
||||
|
||||
/// 构建状态项
|
||||
Widget _buildStatusItem(
|
||||
BuildContext context,
|
||||
String label,
|
||||
Color color,
|
||||
IconData icon,
|
||||
int index,
|
||||
int currentIndex,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
final isSelected = index == currentIndex;
|
||||
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? color.withOpacity(0.1) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isSelected ? color : Colors.transparent,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? color : Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected ? color : Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
color: isSelected ? const Color(0xFF1A1A1A) : const Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user