适配深色模式

This commit is contained in:
DelLevin-Home
2026-05-26 05:10:21 +08:00
parent b36f50827f
commit 73f3795e65
53 changed files with 3846 additions and 3211 deletions

View File

@@ -5,9 +5,9 @@ import 'package:webview_flutter/webview_flutter.dart';
/// 豆瓣影视WebView页面 - 用于抓取影视信息
class DoubanWebViewPage extends StatefulWidget {
final String url;
const DoubanWebViewPage({super.key, required this.url});
@override
State<DoubanWebViewPage> createState() => _DoubanWebViewPageState();
}
@@ -16,21 +16,21 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
late WebViewController _controller;
bool _isLoading = true;
bool _canExtract = false;
bool _isExtracting = false; // 防止重复提取
bool _isExtracting = false; // 防止重复提取
@override
void initState() {
super.initState();
_initWebView();
}
@override
void dispose() {
// 清理 WebView 资源
_controller.loadRequest(Uri.parse('about:blank'));
super.dispose();
}
void _initWebView() {
_controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
@@ -55,23 +55,26 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
)
..loadRequest(Uri.parse(widget.url));
}
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: const Text('豆瓣影视'),
leading: _buildBackButton(),
actions: [
// 提取按钮 - 始终显示
_buildActionButton(
colors: colors,
icon: Icons.auto_fix_high_outlined,
onPressed: _showExtractedInfo,
tooltip: '提取信息',
),
// 刷新按钮
_buildActionButton(
colors: colors,
icon: Icons.refresh,
onPressed: () => _controller.reload(),
tooltip: '刷新',
@@ -83,16 +86,14 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
children: [
WebViewWidget(controller: _controller),
// 加载指示器
if (_isLoading)
const Center(
child: CircularProgressIndicator(),
),
if (_isLoading) const Center(
child: CircularProgressIndicator(),
),
],
),
);
}
/// 构建返回按钮
Widget _buildBackButton() {
return Container(
@@ -121,6 +122,7 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
/// 构建右上角操作按钮
Widget _buildActionButton({
required ColorScheme colors,
required IconData icon,
required VoidCallback onPressed,
required String tooltip,
@@ -138,75 +140,86 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
borderRadius: BorderRadius.circular(8),
child: Container(
padding: const EdgeInsets.all(8),
child: Icon(icon, color: const Color(0xFF1A1A1A), size: 22),
child: Icon(icon, color: colors.onSurface, size: 22),
),
),
),
);
}
/// 显示提取的信息对话框
Future<void> _showExtractedInfo() async {
// 先提取信息
final movieInfo = await _extractMovieInfo();
if (movieInfo == null) return;
// 显示提取的信息
if (mounted) {
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: const Text(
'提取的影视信息',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
),
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildInfoRow('标题', movieInfo['title']?.toString() ?? '未提取到'),
_buildInfoRow('导演', movieInfo['director']?.toString() ?? '未提取到'),
_buildInfoRow('类型', movieInfo['genres']?.toString() ?? '未提取到'),
_buildInfoRow('上映日期', movieInfo['releaseDate']?.toString() ?? '未提取到'),
if (movieInfo['summary'] != null)
_buildInfoRow('简介', movieInfo['summary'].toString().substring(0,
movieInfo['summary'].toString().length > 100 ? 100 : movieInfo['summary'].toString().length) + '...'),
],
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'取消',
style: TextStyle(color: Color(0xFF999999)),
builder: (ctx) {
final colors = Theme.of(ctx).colorScheme;
return AlertDialog(
backgroundColor: colors.surface,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: Text(
'提取的影视信息',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: colors.onSurface,
),
),
TextButton(
onPressed: () {
Navigator.pop(context);
Navigator.pop(context, movieInfo);
},
child: const Text(
'使用此信息',
style: TextStyle(color: Color(0xFF1A1A1A), fontWeight: FontWeight.w600),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildInfoRow(colors, '标题', movieInfo['title']?.toString() ?? '未提取到'),
_buildInfoRow(colors, '导演', movieInfo['director']?.toString() ?? '未提取到'),
_buildInfoRow(colors, '类型', movieInfo['genres']?.toString() ?? '未提取到'),
_buildInfoRow(colors, '上映日期', movieInfo['releaseDate']?.toString() ?? '未提取到'),
if (movieInfo['summary'] != null)
_buildInfoRow(
colors,
'简介',
movieInfo['summary'].toString().substring(
0,
movieInfo['summary'].toString().length > 100
? 100
: movieInfo['summary'].toString().length) +
'...'),
],
),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: Text(
'取消',
style: TextStyle(color: colors.onSurface.withValues(alpha: 0.4)),
),
),
TextButton(
onPressed: () {
Navigator.pop(ctx);
Navigator.pop(context, movieInfo);
},
child: Text(
'使用此信息',
style: TextStyle(
color: colors.onSurface, fontWeight: FontWeight.w600),
),
),
],
);
},
);
}
}
/// 构建信息行
Widget _buildInfoRow(String label, String value) {
Widget _buildInfoRow(ColorScheme colors, String label, String value) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Row(
@@ -216,18 +229,18 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
width: 64,
child: Text(
label,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
),
Expanded(
child: Text(
value,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
),
@@ -240,10 +253,10 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
Future<Map<String, dynamic>?> _extractMovieInfo() async {
// 检查是否已提取过,避免重复点击
if (_isExtracting) return null;
try {
_isExtracting = true;
// 显示加载提示
showDialog(
context: context,
@@ -252,16 +265,16 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
child: CircularProgressIndicator(),
),
);
// 执行JavaScript代码提取页面信息
final result = await _controller.runJavaScriptReturningResult(r'''
(function() {
const info = {};
// 获取标题 - 移动版页面
const titleEl = document.querySelector('.sub-title');
info.title = titleEl ? titleEl.textContent.trim() : '';
// 获取年份 - 从 original-title 中提取
const originalTitleEl = document.querySelector('.sub-original-title');
if (originalTitleEl) {
@@ -270,7 +283,7 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
} else {
info.year = '';
}
// 获取封面图 - 从 sub-cover 中的 img 标签获取
const coverEl = document.querySelector('.sub-cover img');
if (coverEl) {
@@ -283,11 +296,11 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
} else {
info.coverUrl = '';
}
// 获取评分 - 移动版可能在 mark-item 中
const ratingEl = document.querySelector('.rating-num') || document.querySelector('.score');
info.rating = ratingEl ? ratingEl.textContent.trim() : '';
// 获取导演 - 从演职员列表中找
const directorEl = document.querySelector('.movie-celebrities .item__celebrity .role');
if (directorEl && directorEl.textContent.includes('导演')) {
@@ -296,7 +309,7 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
} else {
info.director = '';
}
// 获取编剧 - 从演职员列表中找(匹配"编剧"或"剧本"
const writerEls = document.querySelectorAll('.movie-celebrities .item__celebrity');
const writers = [];
@@ -308,7 +321,7 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
}
});
info.writers = writers;
// 获取主演- 从演职员列表中找前5个
const actorEls = document.querySelectorAll('.movie-celebrities .item__celebrity');
const actors = [];
@@ -316,10 +329,10 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
const roleEl = el
.querySelector('.role');
if (roleEl && (
roleEl.textContent.includes('配音') ||
roleEl.textContent.includes('主演') ||
roleEl.textContent.includes('配音') ||
roleEl.textContent.includes('主演') ||
roleEl.textContent.includes('演员') ||
roleEl.textContent.includes('参演') ||
roleEl.textContent.includes('参演') ||
roleEl.textContent.includes('饰')
)) {
const nameEl = el.querySelector('.name');
@@ -327,20 +340,20 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
}
});
info.actors = actors;
// 获取类型 - 从 sub-meta 或标签中提取
const metaEl = document.querySelector('.sub-meta');
if (metaEl) {
const metaText = metaEl.textContent;
const parts = metaText.split('/').map(s => s.trim());
// 过滤出类型(通常是中文,不是日期,不是时长)
info.genres = parts.filter(p =>
info.genres = parts.filter(p =>
p && !p.match(/^\d{4}/) && !p.includes('分钟') && !p.includes('上映')
).join(',');
} else {
info.genres = '';
}
// 获取上映日期
if (metaEl) {
const dateMatch = metaEl.textContent.match(/(\d{4}-\d{2}-\d{2})/);
@@ -348,7 +361,7 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
} else {
info.releaseDate = '';
}
// 获取简介
const summaryEl = document.querySelector('.subject-intro p');
if (summaryEl) {
@@ -356,7 +369,7 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
} else {
info.summary = '';
}
// 获取别名 - 从 original-title 中提取(去掉年份)
if (originalTitleEl) {
const fullText = originalTitleEl.textContent.trim();
@@ -364,14 +377,14 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
} else {
info.alternateTitles = [];
}
return JSON.stringify(info);
})()
''');
// 关闭加载提示
if (mounted) Navigator.pop(context);
// 解析提取的信息
// result 是 JavaScript 执行结果,已经是 JSON 字符串(带引号的)
final String jsonStr = result.toString();
@@ -380,12 +393,12 @@ class _DoubanWebViewPageState extends State<DoubanWebViewPage> {
? jsonDecode(jsonStr) as String
: jsonStr;
final Map<String, dynamic> movieInfo = jsonDecode(cleanJson) as Map<String, dynamic>;
return movieInfo;
} catch (e) {
// 关闭加载提示
if (mounted) Navigator.pop(context);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('提取信息失败: $e')),

View File

@@ -16,9 +16,9 @@ import 'movie_share_page.dart';
/// 影视详情页 - 极简主义设计
class MovieDetailPage extends StatefulWidget {
final Movie movie;
const MovieDetailPage({super.key, required this.movie});
@override
State<MovieDetailPage> createState() => _MovieDetailPageState();
}
@@ -27,77 +27,53 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
// 页面获得焦点时刷新数据
_refreshMovieData();
}
void _refreshMovieData() {
final provider = context.read<AppProvider>();
// 强制刷新当前影视数据
provider.loadMovies();
}
@override
Widget build(BuildContext context) {
// 从 Provider 获取最新的 movie 数据,实现动态刷新
final colors = Theme.of(context).colorScheme;
final movie = context.watch<AppProvider>().movies
.where((m) => m.id == widget.movie.id)
.firstOrNull ?? widget.movie;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
body: Stack(
children: [
CustomScrollView(
slivers: [
// 顶部海报区域
_buildSliverAppBar(movie),
// 内容区域
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 基本信息
_buildBasicInfo(movie),
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
// 导演
Divider(height: 0.5, thickness: 0.5, color: colors.outline),
if (movie.directors.isNotEmpty)
_buildDirectorsSection(movie),
// 编剧
if (movie.writers.isNotEmpty)
_buildWritersSection(movie),
// 主演
if (movie.actors.isNotEmpty)
_buildActorsSection(movie),
// 类型
if (movie.genres.isNotEmpty)
_buildGenresSection(movie),
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
// 简介
Divider(height: 0.5, thickness: 0.5, color: colors.outline),
if (movie.summary != null && movie.summary!.isNotEmpty)
_buildSummarySection(movie),
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
// 影评和海报墙入口
Divider(height: 0.5, thickness: 0.5, color: colors.outline),
_buildExtraSections(movie),
const SizedBox(height: 120),
],
),
),
],
),
// 右下角悬浮按钮组
Positioned(
right: 16,
bottom: 24,
@@ -107,9 +83,9 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
/// 构建右下角悬浮按钮组
Widget _buildFloatingActionButtons(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -117,13 +93,16 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
icon: Icons.edit_outlined,
onPressed: () => _navigateToEdit(context),
tooltip: '编辑',
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
),
const SizedBox(height: 12),
_buildFloatingButton(
icon: Icons.delete_outline,
onPressed: () => _showDeleteDialog(context),
tooltip: '删除',
backgroundColor: Colors.red,
backgroundColor: colors.error,
foregroundColor: colors.onError,
),
const SizedBox(height: 12),
_buildFloatingButton(
@@ -131,17 +110,18 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
onPressed: () => _showSharePoster(movie),
tooltip: '分享海报',
backgroundColor: const Color(0xFF4CAF50),
foregroundColor: Colors.white,
),
],
);
}
/// 构建单个悬浮按钮
Widget _buildFloatingButton({
required IconData icon,
required VoidCallback onPressed,
required String tooltip,
Color backgroundColor = const Color(0xFF1A1A1A),
required Color backgroundColor,
required Color foregroundColor,
}) {
return Material(
color: Colors.transparent,
@@ -160,15 +140,15 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
],
),
child: IconButton(
icon: Icon(icon, size: 18, color: Colors.white),
icon: Icon(icon, size: 18, color: foregroundColor),
onPressed: onPressed,
padding: EdgeInsets.zero,
tooltip: tooltip,
),
),
);
}
/// 构建带背景的返回按钮
Widget _buildBackButton() {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
@@ -194,21 +174,19 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
);
}
/// 构建顶部 AppBar
Widget _buildSliverAppBar(Movie movie) {
final colors = Theme.of(context).colorScheme;
return SliverAppBar(
expandedHeight: 320,
pinned: true,
backgroundColor: const Color(0xFFF5F5F5),
backgroundColor: colors.surfaceContainerHighest,
leading: _buildBackButton(),
flexibleSpace: FlexibleSpaceBar(
background: _buildPosterSection(movie),
),
// 右上角按钮已移到右下角悬浮按钮
);
}
/// 构建海报区域
Widget _buildPosterSection(Movie movie) {
return SizedBox.expand(
child: movie.posterPath != null && movie.posterPath!.isNotEmpty
@@ -220,79 +198,74 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
: _buildPosterPlaceholder(),
);
}
Widget _buildPosterPlaceholder() {
return const Center(
final colors = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.movie_outlined,
size: 64,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
SizedBox(height: 16),
const SizedBox(height: 16),
Text(
'暂无海报',
style: TextStyle(
fontSize: 14,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
],
),
);
}
/// 构建基本信息
Widget _buildBasicInfo(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 影视名称
Text(
movie.title,
style: const TextStyle(
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.3,
),
),
// 别名(显示在主名称下面,用 / 分隔)
if (movie.alternateTitles.isNotEmpty) ...[
const SizedBox(height: 8),
Text(
movie.alternateTitles.join(' / '),
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
height: 1.4,
),
),
],
const SizedBox(height: 16),
// 评分和状态
Row(
children: [
if (movie.rating != null) ...[
const Icon(
Icon(
Icons.star,
size: 20,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
const SizedBox(width: 4),
Text(
movie.rating!.toStringAsFixed(1),
style: const TextStyle(
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
const SizedBox(width: 16),
@@ -300,62 +273,56 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
_buildStatusTag(movie),
],
),
const SizedBox(height: 8),
// 上映日期
if (movie.releaseDate != null)
Text(
'${movie.releaseDate!.year}${movie.releaseDate!.month.toString().padLeft(2, '0')}月上映',
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
const SizedBox(height: 8),
// 观看日期
if (movie.watchDate != null)
Text(
'观看于 ${_formatDate(movie.watchDate!)}',
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
],
),
);
}
/// 构建状态标签
Widget _buildStatusTag(Movie movie) {
final colors = Theme.of(context).colorScheme;
String label;
Color bgColor;
Color textColor;
switch (movie.status) {
case 'watched':
label = '已看';
bgColor = const Color(0xFF1A1A1A);
textColor = Colors.white;
bgColor = colors.primary;
textColor = colors.onPrimary;
break;
case 'watching':
label = '在看';
bgColor = const Color(0xFFF0F0F0);
textColor = const Color(0xFF666666);
bgColor = colors.outlineVariant;
textColor = colors.onSurface.withValues(alpha: 0.6);
break;
case 'want_to_watch':
label = '想看';
bgColor = const Color(0xFFF5F5F5);
textColor = const Color(0xFF999999);
bgColor = colors.surfaceContainerHighest;
textColor = colors.onSurface.withValues(alpha: 0.4);
break;
default:
label = '未知';
bgColor = const Color(0xFFEEEEEE);
textColor = const Color(0xFFCCCCCC);
bgColor = colors.outlineVariant;
textColor = colors.onSurface.withValues(alpha: 0.25);
}
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
@@ -372,30 +339,30 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
/// 构建导演区域
Widget _buildDirectorsSection(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
SizedBox(
width: 48,
child: Text(
'导演',
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
),
Expanded(
child: Text(
movie.directors.join(''),
style: const TextStyle(
style: TextStyle(
fontSize: 15,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.5,
),
),
@@ -405,29 +372,29 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
);
}
/// 构建编剧区域
Widget _buildWritersSection(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
SizedBox(
width: 48,
child: Text(
'编剧',
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
),
Expanded(
child: Text(
movie.writers.join(''),
style: const TextStyle(
style: TextStyle(
fontSize: 15,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.5,
),
),
@@ -437,29 +404,29 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
);
}
/// 构建主演区域
Widget _buildActorsSection(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
SizedBox(
width: 48,
child: Text(
'主演',
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
),
Expanded(
child: Text(
movie.actors.join(''),
style: const TextStyle(
style: TextStyle(
fontSize: 15,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.5,
),
),
@@ -469,20 +436,20 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
);
}
/// 构建类型区域
Widget _buildGenresSection(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
SizedBox(
width: 48,
child: Text(
'类型',
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
),
@@ -494,14 +461,14 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(4),
),
child: Text(
genre,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
),
),
);
@@ -512,9 +479,9 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
/// 构建简介区域
Widget _buildSummarySection(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.all(24),
child: Column(
@@ -526,17 +493,17 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
width: 4,
height: 16,
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
color: colors.onSurface,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(width: 8),
const Text(
Text(
'简介',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
],
@@ -545,14 +512,14 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: const Color(0xFFFAFAFA),
color: colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(12),
),
child: Text(
movie.summary!,
style: const TextStyle(
style: TextStyle(
fontSize: 15,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.8,
),
),
@@ -561,9 +528,9 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
/// 构建额外功能区域(影评、海报墙)
Widget _buildExtraSections(Movie movie) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.all(24),
child: Column(
@@ -575,23 +542,22 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
width: 4,
height: 16,
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
color: colors.onSurface,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(width: 8),
const Text(
Text(
'更多',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
],
),
const SizedBox(height: 16),
// 影评入口
_buildExtraSectionItem(
icon: Icons.rate_review_outlined,
title: '影评',
@@ -601,7 +567,6 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
onTap: () => _navigateToReviews(movie),
),
const SizedBox(height: 12),
// 海报墙入口
_buildExtraSectionItem(
icon: Icons.photo_library_outlined,
title: '海报墙',
@@ -615,7 +580,6 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
);
}
/// 构建更多区域项
Widget _buildExtraSectionItem({
required IconData icon,
required String title,
@@ -624,14 +588,15 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
required String unit,
required VoidCallback onTap,
}) {
final colors = Theme.of(context).colorScheme;
return GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0xFFFAFAFA),
color: colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
border: Border.all(color: colors.outlineVariant, width: 0.5),
),
child: Row(
children: [
@@ -639,14 +604,14 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
border: Border.all(color: colors.outlineVariant, width: 0.5),
),
child: Icon(
icon,
size: 20,
color: const Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
),
),
const SizedBox(width: 12),
@@ -656,10 +621,10 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
children: [
Text(
title,
style: const TextStyle(
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
const SizedBox(height: 4),
@@ -669,9 +634,9 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
final count = snapshot.data ?? 0;
return Text(
count > 0 ? '$count $unit' : emptyText,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
);
},
@@ -679,16 +644,16 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
],
),
),
const Icon(
Icon(
Icons.chevron_right,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
],
),
),
);
}
void _navigateToReviews(Movie movie) {
Navigator.push(
context,
@@ -697,7 +662,7 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
void _navigateToPosters(Movie movie) {
Navigator.push(
context,
@@ -706,39 +671,38 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
/// 格式化日期
String _formatDate(DateTime date) {
return '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
}
/// 跳转到编辑页面
void _navigateToEdit(BuildContext context) {
Navigator.pushNamed(context, '/movie-form', arguments: widget.movie).then((_) {
context.read<AppProvider>().loadMovies();
});
}
/// 显示删除对话框
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(
'确定要删除"${widget.movie.title}"吗?删除后可在回收站恢复。',
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
height: 1.5,
),
),
@@ -746,7 +710,7 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
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('取消'),
@@ -760,8 +724,8 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
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),
@@ -775,18 +739,14 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
),
);
}
/// 请求存储权限
Future<bool> _requestStoragePermission() async {
// Android 13+ 使用新的权限
if (Platform.isAndroid) {
final sdkInt = await _getAndroidSdkInt();
if (sdkInt >= 33) {
// Android 13+ 使用 READ_MEDIA_IMAGES
final status = await Permission.photos.request();
return status.isGranted;
} else {
// Android 12 及以下使用存储权限
var status = await Permission.storage.request();
if (status.isDenied) {
status = await Permission.storage.request();
@@ -794,18 +754,13 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
return status.isGranted;
}
}
// iOS 不需要额外权限来保存到应用沙盒
return true;
}
/// 获取 Android SDK 版本
Future<int> _getAndroidSdkInt() async {
// 简化处理,实际可以通过 platform channel 获取
// 这里默认返回较低版本,使用传统存储权限
return 30;
}
/// 显示分享海报页面
void _showSharePoster(Movie movie) {
Navigator.push(
context,

File diff suppressed because it is too large Load Diff

View File

@@ -45,8 +45,9 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: const Text('海报墙'),
actions: [
@@ -66,6 +67,7 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
}
Widget _buildEmptyState() {
final colors = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -74,21 +76,21 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
width: 80,
height: 80,
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(20),
),
child: const Icon(
child: Icon(
Icons.photo_library_outlined,
size: 40,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
),
const SizedBox(height: 20),
const Text(
Text(
'暂无海报',
style: TextStyle(
fontSize: 16,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
const SizedBox(height: 24),
@@ -97,15 +99,15 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
color: colors.primary,
borderRadius: BorderRadius.circular(8),
),
child: const Text(
child: Text(
'添加记录',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white,
color: colors.onPrimary,
),
),
),
@@ -130,10 +132,11 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
}
Widget _buildPosterItem(MoviePoster poster, int index) {
final colors = Theme.of(context).colorScheme;
// 根据索引生成不同的高度,实现瀑布流效果
final heights = [180.0, 220.0, 160.0, 200.0, 240.0, 190.0];
final height = heights[index % heights.length];
return GestureDetector(
onTap: () => _showPosterDetail(poster),
onLongPress: () => _showDeleteDialog(poster),
@@ -158,10 +161,10 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
Image.file(
File(poster.posterPath),
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const Center(
errorBuilder: (_, __, ___) => Center(
child: Icon(
Icons.broken_image,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
),
),
@@ -194,7 +197,7 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
void _showPosterDetail(MoviePoster poster) {
// 找到当前海报的索引
final initialIndex = _posters.indexWhere((p) => p.id == poster.id);
Navigator.push(
context,
MaterialPageRoute(
@@ -210,61 +213,72 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
// 显示选择对话框
final result = await showModalBottomSheet<int>(
context: context,
backgroundColor: Colors.white,
backgroundColor: Colors.transparent,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (context) => 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),
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 20),
// 标题
const Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Row(
children: [
Text(
'添加海报',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
),
),
],
),
),
const SizedBox(height: 16),
// 从相册选择
_buildAddOption(
icon: Icons.photo_library_outlined,
title: '从相册选择',
subtitle: '选择本地图片',
onTap: () => Navigator.pop(context, 0),
),
// 网络链接
_buildAddOption(
icon: Icons.link_outlined,
title: '网络链接',
subtitle: '输入图片URL地址',
onTap: () => Navigator.pop(context, 1),
),
],
builder: (context) {
final colors = Theme.of(context).colorScheme;
return Container(
decoration: BoxDecoration(
color: colors.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
),
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// 顶部指示条
Container(
width: 40,
height: 4,
decoration: BoxDecoration(
color: colors.outline,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 20),
// 标题
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Row(
children: [
Text(
'添加海报',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: colors.onSurface,
),
),
],
),
),
const SizedBox(height: 16),
// 从相册选择
_buildAddOption(
colors: colors,
icon: Icons.photo_library_outlined,
title: '从相册选择',
subtitle: '选择本地图片',
onTap: () => Navigator.pop(context, 0),
),
// 网络链接
_buildAddOption(
colors: colors,
icon: Icons.link_outlined,
title: '网络链接',
subtitle: '输入图片URL地址',
onTap: () => Navigator.pop(context, 1),
),
],
),
),
),
);
},
);
if (result == null) return;
@@ -289,10 +303,10 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
if (pickedFile != null) {
// 生成文件名
final fileName = 'posterimg_${DateTime.now().millisecondsSinceEpoch}.jpg';
// 保存到 posterimgs 子目录: images/movies/{movieId}/posterimgs/{fileName}
final targetPath = await ImagePathHelper.instance.getMoviePosterImgPath(
widget.movie.id,
widget.movie.id,
fileName
);
await ImagePathHelper.instance.ensureDirExists(p.dirname(targetPath));
@@ -323,55 +337,58 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
/// 从网络链接添加
Future<void> _pickFromUrl() async {
final urlController = TextEditingController();
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('添加网络图片'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'请输入图片链接地址',
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
builder: (context) {
final colors = Theme.of(context).colorScheme;
return AlertDialog(
backgroundColor: colors.surface,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('添加网络图片'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'请输入图片链接地址',
style: TextStyle(
fontSize: 14,
color: colors.onSurface.withValues(alpha: 0.6),
),
),
const SizedBox(height: 12),
TextField(
controller: urlController,
decoration: InputDecoration(
hintText: 'https://example.com/image.jpg',
hintStyle: TextStyle(color: colors.onSurface.withValues(alpha: 0.25)),
border: const UnderlineInputBorder(),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: colors.outline),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: colors.primary),
),
),
style: const TextStyle(fontSize: 14),
keyboardType: TextInputType.url,
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.6))),
),
const SizedBox(height: 12),
TextField(
controller: urlController,
decoration: const InputDecoration(
hintText: 'https://example.com/image.jpg',
hintStyle: TextStyle(color: Color(0xFFCCCCCC)),
border: UnderlineInputBorder(),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xFFE5E5E5)),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Color(0xFF1A1A1A)),
),
),
style: const TextStyle(fontSize: 14),
keyboardType: TextInputType.url,
TextButton(
onPressed: () => Navigator.pop(context, true),
child: Text('确定', style: TextStyle(color: colors.onSurface)),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('确定', style: TextStyle(color: Color(0xFF1A1A1A))),
),
],
),
);
},
);
if (confirmed != true) return;
@@ -404,7 +421,7 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
'Referer': Uri.parse(url).replace(path: '/').toString(),
},
);
if (response.statusCode != 200) {
throw Exception('下载失败: HTTP ${response.statusCode}');
}
@@ -422,10 +439,10 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
// 生成文件名
final fileName = 'posterimg_${DateTime.now().millisecondsSinceEpoch}.jpg';
// 保存到 posterimgs 子目录
final targetPath = await ImagePathHelper.instance.getMoviePosterImgPath(
widget.movie.id,
widget.movie.id,
fileName
);
await ImagePathHelper.instance.ensureDirExists(p.dirname(targetPath));
@@ -453,6 +470,7 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
/// 构建添加选项
Widget _buildAddOption({
required ColorScheme colors,
required IconData icon,
required String title,
required String subtitle,
@@ -468,13 +486,13 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
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),
@@ -484,26 +502,26 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
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,
),
],
@@ -515,28 +533,31 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
void _showDeleteDialog(MoviePoster poster) {
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('确认删除'),
content: const Text('确定要删除这张海报吗?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
),
TextButton(
onPressed: () async {
await context.read<AppProvider>().removeMoviePoster(poster.id);
Navigator.pop(context);
_loadPosters();
ToastUtil.show(context, '已删除');
},
child: const Text('删除', style: TextStyle(color: Colors.red)),
),
],
),
builder: (context) {
final colors = Theme.of(context).colorScheme;
return AlertDialog(
backgroundColor: colors.surface,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('确认删除'),
content: const Text('确定要删除这张海报吗?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.6))),
),
TextButton(
onPressed: () async {
await context.read<AppProvider>().removeMoviePoster(poster.id);
Navigator.pop(context);
_loadPosters();
ToastUtil.show(context, '删除');
},
child: Text('删除', style: TextStyle(color: colors.error)),
),
],
);
},
);
}
}

View File

@@ -49,8 +49,9 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: const Text('影评详情'),
actions: [
@@ -70,9 +71,9 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
// 影评内容
Text(
_review.content,
style: const TextStyle(
style: TextStyle(
fontSize: 16,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.8,
),
),
@@ -82,7 +83,7 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
// 分隔线
Container(
height: 0.5,
color: const Color(0xFFE5E5E5),
color: colors.outline,
),
const SizedBox(height: 24),
@@ -92,6 +93,7 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
icon: Icons.person_outline,
label: '影评人:',
value: _review.reviewer.isNotEmpty ? _review.reviewer : '匿名',
colors: colors,
),
const SizedBox(height: 16),
@@ -102,6 +104,7 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
icon: Icons.source_outlined,
label: '来源:',
value: _review.source,
colors: colors,
),
if (_review.source.isNotEmpty) const SizedBox(height: 16),
@@ -111,6 +114,7 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
icon: Icons.category_outlined,
label: '类型:',
value: _review.typeText,
colors: colors,
),
const SizedBox(height: 16),
@@ -120,6 +124,7 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
icon: Icons.access_time,
label: '时间:',
value: _formatDate(_review.createdAt),
colors: colors,
),
],
),
@@ -132,13 +137,14 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
required IconData icon,
required String label,
required String value,
required ColorScheme colors,
}) {
return Row(
children: [
Icon(
icon,
size: 20,
color: const Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
const SizedBox(width: 12),
// 固定宽度容器,以"影评人:"的最大宽度为准
@@ -146,18 +152,18 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
width: 64,
child: Text(
label,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
),
Expanded(
child: Text(
value,
style: const TextStyle(
style: TextStyle(
fontSize: 15,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
),

View File

@@ -46,10 +46,11 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
final isEdit = widget.review != null;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: Text(isEdit ? '编辑影评' : '写影评'),
actions: [
@@ -73,24 +74,24 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
// 顶部信息栏
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: const BoxDecoration(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
bottom: BorderSide(color: colors.outline, width: 0.5),
),
),
child: Row(
children: [
// 类型选择
_buildTypeSelector(),
_buildTypeSelector(colors),
const SizedBox(width: 16),
// 评论人
Expanded(
child: TextField(
controller: _reviewerController,
style: const TextStyle(fontSize: 14, color: Color(0xFF1A1A1A)),
decoration: const InputDecoration(
style: TextStyle(fontSize: 14, color: colors.onSurface),
decoration: InputDecoration(
hintText: '评论人',
hintStyle: TextStyle(fontSize: 14, color: Color(0xFFCCCCCC)),
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)),
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
@@ -103,10 +104,10 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
width: 100,
child: TextField(
controller: _sourceController,
style: const TextStyle(fontSize: 14, color: Color(0xFF1A1A1A)),
decoration: const InputDecoration(
style: TextStyle(fontSize: 14, color: colors.onSurface),
decoration: InputDecoration(
hintText: '来源',
hintStyle: TextStyle(fontSize: 14, color: Color(0xFFCCCCCC)),
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)),
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
@@ -116,7 +117,7 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
],
),
),
// 评论内容区域
Expanded(
child: TextFormField(
@@ -124,19 +125,19 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
maxLines: null,
expands: true,
textAlignVertical: TextAlignVertical.top,
style: const TextStyle(
style: TextStyle(
fontSize: 16,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.7,
),
decoration: const InputDecoration(
decoration: InputDecoration(
hintText: '写下你的影评...',
hintStyle: TextStyle(
fontSize: 16,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
border: InputBorder.none,
contentPadding: EdgeInsets.all(16),
contentPadding: const EdgeInsets.all(16),
),
validator: (value) {
if (value == null || value.trim().isEmpty) {
@@ -153,29 +154,29 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
}
/// 构建类型选择器
Widget _buildTypeSelector() {
Widget _buildTypeSelector(ColorScheme colors) {
return GestureDetector(
onTap: () => _showTypeSelector(),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFFE5E5E5)),
border: Border.all(color: colors.outline),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
_reviewType == 1 ? '短评' : '长评',
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
),
),
const SizedBox(width: 4),
const Icon(
Icon(
Icons.arrow_drop_down,
size: 16,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
],
),
@@ -187,36 +188,42 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
void _showTypeSelector() {
showModalBottomSheet(
context: context,
backgroundColor: Colors.white,
backgroundColor: Colors.transparent,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
builder: (context) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: const Text('短评'),
trailing: _reviewType == 1
? const Icon(Icons.check, color: Color(0xFF1A1A1A))
: null,
onTap: () {
setState(() => _reviewType = 1);
Navigator.pop(context);
},
builder: (context) {
final colors = Theme.of(context).colorScheme;
return Container(
color: colors.surface,
child: SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
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);
},
),
],
),
const Divider(height: 0.5),
ListTile(
title: const Text('长评'),
trailing: _reviewType == 2
? const Icon(Icons.check, color: Color(0xFF1A1A1A))
: null,
onTap: () {
setState(() => _reviewType = 2);
Navigator.pop(context);
},
),
],
),
),
),
);
},
);
}

View File

@@ -73,19 +73,20 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: _isSearching
? TextField(
controller: _searchController,
autofocus: true,
decoration: const InputDecoration(
decoration: InputDecoration(
hintText: '搜索影评内容、评论人、来源...',
hintStyle: TextStyle(color: Color(0xFF999999)),
hintStyle: TextStyle(color: colors.onSurface.withValues(alpha: 0.4)),
border: InputBorder.none,
),
style: const TextStyle(color: Color(0xFF1A1A1A)),
style: TextStyle(color: colors.onSurface),
onChanged: _onSearchChanged,
)
: const Text('影评'),
@@ -112,6 +113,7 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
}
Widget _buildEmptyState() {
final colors = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -120,21 +122,21 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
width: 80,
height: 80,
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(20),
),
child: const Icon(
child: Icon(
Icons.rate_review_outlined,
size: 40,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
),
const SizedBox(height: 20),
const Text(
Text(
'暂无影评',
style: TextStyle(
fontSize: 16,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
const SizedBox(height: 24),
@@ -143,15 +145,15 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
color: colors.primary,
borderRadius: BorderRadius.circular(8),
),
child: const Text(
child: Text(
'添加记录',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white,
color: colors.onPrimary,
),
),
),
@@ -176,13 +178,14 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
}
Widget _buildReviewCard(MovieReview review) {
final colors = Theme.of(context).colorScheme;
return InkWell(
onTap: () => _navigateToReviewDetail(review),
onLongPress: () => _showDeleteDialog(review),
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
),
child: Column(
@@ -193,8 +196,8 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: review.reviewType == 1
? Colors.white
: const Color(0xFF1A1A1A),
? colors.surface
: colors.primary,
borderRadius: BorderRadius.circular(4),
),
child: Text(
@@ -202,8 +205,8 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
style: TextStyle(
fontSize: 10,
color: review.reviewType == 1
? const Color(0xFF666666)
: Colors.white,
? colors.onSurface.withValues(alpha: 0.6)
: colors.onPrimary,
),
),
),
@@ -215,9 +218,9 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
review.content,
maxLines: review.reviewType == 1 ? 4 : 8,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.5,
),
),
@@ -232,9 +235,9 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
Expanded(
child: Text(
review.reviewer,
style: const TextStyle(
style: TextStyle(
fontSize: 11,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
),
overflow: TextOverflow.ellipsis,
),
@@ -252,9 +255,9 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
Expanded(
child: Text(
review.source,
style: const TextStyle(
style: TextStyle(
fontSize: 10,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
overflow: TextOverflow.ellipsis,
),
@@ -262,9 +265,9 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
// 日期
Text(
_formatDate(review.createdAt),
style: const TextStyle(
style: TextStyle(
fontSize: 10,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
],
@@ -315,28 +318,31 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
void _showDeleteDialog(MovieReview review) {
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('确认删除'),
content: const Text('确定要删除这条影评吗?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
),
TextButton(
onPressed: () async {
await context.read<AppProvider>().removeMovieReview(review.id);
Navigator.pop(context);
_loadReviews();
ToastUtil.show(context, '已删除');
},
child: const Text('删除', style: TextStyle(color: Colors.red)),
),
],
),
builder: (context) {
final colors = Theme.of(context).colorScheme;
return AlertDialog(
backgroundColor: colors.surface,
elevation: 0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
title: const Text('确认删除'),
content: const Text('确定要删除这条影评吗?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.6))),
),
TextButton(
onPressed: () async {
await context.read<AppProvider>().removeMovieReview(review.id);
Navigator.pop(context);
_loadReviews();
ToastUtil.show(context, '删除');
},
child: Text('删除', style: TextStyle(color: colors.error)),
),
],
);
},
);
}
}
}

View File

@@ -24,21 +24,22 @@ class _MovieSharePageState extends State<MovieSharePage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
backgroundColor: colors.surfaceContainerHighest,
appBar: AppBar(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.close, color: Color(0xFF1A1A1A)),
icon: Icon(Icons.close, color: colors.onSurface),
onPressed: () => Navigator.pop(context),
),
title: const Text(
title: Text(
'分享海报',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
centerTitle: true,
@@ -51,12 +52,12 @@ class _MovieSharePageState extends State<MovieSharePage> {
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Text(
: Text(
'分享',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
),
@@ -77,13 +78,14 @@ class _MovieSharePageState extends State<MovieSharePage> {
/// 构建海报 Widget
Widget _buildPosterWidget() {
final colors = Theme.of(context).colorScheme;
final movie = widget.movie;
final hasPoster = movie.posterPath != null && movie.posterPath!.isNotEmpty;
return Container(
width: 320,
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
@@ -118,10 +120,10 @@ class _MovieSharePageState extends State<MovieSharePage> {
// 标题
Text(
movie.title,
style: const TextStyle(
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
@@ -130,9 +132,9 @@ class _MovieSharePageState extends State<MovieSharePage> {
const SizedBox(height: 8),
Text(
movie.alternateTitles.join(' / '),
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
),
),
],
@@ -158,11 +160,11 @@ class _MovieSharePageState extends State<MovieSharePage> {
),
),
const SizedBox(width: 4),
const Text(
Text(
'/ 10',
style: TextStyle(
fontSize: 12,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
],
@@ -172,44 +174,45 @@ class _MovieSharePageState extends State<MovieSharePage> {
// 导演
if (movie.directors.isNotEmpty)
_buildInfoRow('导演', movie.directors.join(' / ')),
_buildInfoRow('导演', movie.directors.join(' / '), colors),
// 编剧
if (movie.writers.isNotEmpty)
_buildInfoRow('编剧', movie.writers.join(' / ')),
_buildInfoRow('编剧', movie.writers.join(' / '), colors),
// 主演
if (movie.actors.isNotEmpty)
_buildInfoRow('主演', movie.actors.take(3).join(' / ')),
_buildInfoRow('主演', movie.actors.take(3).join(' / '), colors),
// 类型
if (movie.genres.isNotEmpty)
_buildInfoRow('类型', movie.genres.join(' / ')),
_buildInfoRow('类型', movie.genres.join(' / '), colors),
// 上映日期
if (movie.releaseDate != null)
_buildInfoRow(
'上映',
'${movie.releaseDate!.year}.${movie.releaseDate!.month.toString().padLeft(2, '0')}.${movie.releaseDate!.day.toString().padLeft(2, '0')}',
colors,
),
const SizedBox(height: 16),
// 简介
if (movie.summary != null && movie.summary!.isNotEmpty) ...[
const Text(
Text(
'简介',
style: TextStyle(
fontSize: 12,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
const SizedBox(height: 8),
Text(
movie.summary!,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
height: 1.6,
),
maxLines: 5,
@@ -220,7 +223,7 @@ class _MovieSharePageState extends State<MovieSharePage> {
const SizedBox(height: 20),
// 底部标识
const Divider(height: 1, color: Color(0xFFE8E8E8)),
Divider(height: 1, color: colors.outline),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
@@ -228,14 +231,14 @@ class _MovieSharePageState extends State<MovieSharePage> {
Icon(
Icons.movie_outlined,
size: 14,
color: const Color(0xFF1A1A1A).withOpacity(0.5),
color: colors.onSurface.withValues(alpha: 0.5),
),
const SizedBox(width: 6),
Text(
'来自 MookNote',
style: TextStyle(
fontSize: 12,
color: const Color(0xFF1A1A1A).withOpacity(0.5),
color: colors.onSurface.withValues(alpha: 0.5),
),
),
],
@@ -249,7 +252,7 @@ class _MovieSharePageState extends State<MovieSharePage> {
}
/// 构建信息行
Widget _buildInfoRow(String label, String value) {
Widget _buildInfoRow(String label, String value, ColorScheme colors) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Row(
@@ -257,17 +260,17 @@ class _MovieSharePageState extends State<MovieSharePage> {
children: [
Text(
'$label',
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
Expanded(
child: Text(
value,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF333333),
color: colors.onSurface.withValues(alpha: 0.75),
),
),
),

View File

@@ -17,7 +17,7 @@ class MovieTabPage extends StatefulWidget {
}
class _MovieTabPageState extends State<MovieTabPage> {
int _layoutStyle = 0; // 0: 海报网格, 1: 列表
int _layoutStyle = 0;
bool _firstLoad = true;
@override
@@ -31,10 +31,11 @@ class _MovieTabPageState extends State<MovieTabPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Column(
children: [
const MovieStatusBar(),
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
Divider(height: 0.5, thickness: 0.5, color: colors.outline),
Expanded(
child: _buildMovieList(context),
),
@@ -43,12 +44,12 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
Widget _buildMovieList(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Consumer<AppProvider>(
builder: (context, provider, child) {
final statusMap = {0: 'watched', 1: 'watching', 2: 'want_to_watch'};
final currentStatus = statusMap[provider.movieStatusIndex]!;
final allMovies = provider.movies.where((m) => !m.isDeleted).toList();
// 首次加载且数据为空时才显示骨架屏
if (_firstLoad && allMovies.isEmpty) {
return _buildSkeleton();
}
@@ -59,8 +60,8 @@ class _MovieTabPageState extends State<MovieTabPage> {
if (movies.isEmpty) {
return RefreshIndicator(
onRefresh: () async => await provider.loadMovies(),
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: [_buildEmptyState(context, provider.movieStatusIndex)],
@@ -77,10 +78,11 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
Widget _buildGridView(List movies, AppProvider provider) {
final colors = Theme.of(context).colorScheme;
return RefreshIndicator(
onRefresh: () async => await provider.loadMovies(),
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: GridView.builder(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 100),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
@@ -96,10 +98,11 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
Widget _buildListView(List movies, AppProvider provider) {
final colors = Theme.of(context).colorScheme;
return RefreshIndicator(
onRefresh: () async => await provider.loadMovies(),
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: ListView.builder(
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
itemCount: movies.length,
@@ -109,6 +112,7 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
Widget _buildListCard(movie) {
final colors = Theme.of(context).colorScheme;
return GestureDetector(
onTap: () => Navigator.pushNamed(context, '/movie-detail', arguments: movie),
onLongPress: () => _showDeleteDialog(context, movie),
@@ -116,23 +120,22 @@ class _MovieTabPageState extends State<MovieTabPage> {
margin: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xFFFAFAFA),
color: colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
// 海报缩略图
Container(
width: 48, height: 64,
decoration: BoxDecoration(
color: const Color(0xFFF0F0F0),
color: colors.outlineVariant,
borderRadius: BorderRadius.circular(6),
),
clipBehavior: Clip.antiAlias,
child: movie.posterPath != null && movie.posterPath!.isNotEmpty
? Image.file(File(movie.posterPath!), fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const Icon(Icons.movie_outlined, size: 22, color: Color(0xFFCCCCCC)))
: const Icon(Icons.movie_outlined, size: 22, color: Color(0xFFCCCCCC)),
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(
@@ -140,11 +143,11 @@ class _MovieTabPageState extends State<MovieTabPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(movie.title, maxLines: 1, overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A))),
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface)),
if (movie.alternateTitles.isNotEmpty) ...[
const SizedBox(height: 3),
Text(movie.alternateTitles.take(2).join(''), 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: 6),
if (movie.rating != null)
@@ -155,7 +158,7 @@ class _MovieTabPageState extends State<MovieTabPage> {
),
),
const SizedBox(width: 8),
const Icon(Icons.chevron_right, color: Color(0xFFD0D0D0), size: 20),
Icon(Icons.chevron_right, color: colors.onSurface.withValues(alpha: 0.2), size: 20),
],
),
),
@@ -163,19 +166,20 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
void _showDeleteDialog(BuildContext context, movie) {
final colors = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (ctx) => AlertDialog(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: const Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
title: Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)),
content: Text('确定要删除《${movie.title}》吗?删除后可在回收站恢复。',
style: const TextStyle(fontSize: 14, color: Color(0xFF666666), height: 1.5)),
style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.6), height: 1.5)),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.6))),
),
ElevatedButton(
onPressed: () async {
@@ -183,7 +187,7 @@ class _MovieTabPageState extends State<MovieTabPage> {
Navigator.pop(ctx);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red, foregroundColor: Colors.white, elevation: 0,
backgroundColor: colors.error, foregroundColor: colors.onError, elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
@@ -200,6 +204,7 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
Widget _buildListSkeleton() {
final colors = Theme.of(context).colorScheme;
return ListView.builder(
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
itemCount: 6,
@@ -207,7 +212,7 @@ class _MovieTabPageState extends State<MovieTabPage> {
margin: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xFFF8F8F8),
color: colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(12),
),
child: const Row(
@@ -235,6 +240,7 @@ class _MovieTabPageState extends State<MovieTabPage> {
}
Widget _buildEmptyState(BuildContext context, int statusIndex) {
final colors = Theme.of(context).colorScheme;
final statusText = ['已看', '在看', '想看'][statusIndex];
return Center(
child: Column(
@@ -242,11 +248,11 @@ class _MovieTabPageState extends State<MovieTabPage> {
children: [
Container(
width: 80, height: 80,
decoration: BoxDecoration(color: const Color(0xFFF5F5F5), borderRadius: BorderRadius.circular(20)),
child: const Icon(Icons.movie_outlined, size: 40, color: Color(0xFFCCCCCC)),
decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(20)),
child: Icon(Icons.movie_outlined, size: 40, color: colors.onSurface.withValues(alpha: 0.25)),
),
const SizedBox(height: 20),
Text('暂无$statusText的影片', style: const TextStyle(fontSize: 16, color: Color(0xFF999999))),
Text('暂无$statusText的影片', style: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))),
const SizedBox(height: 24),
InkWell(
onTap: () {
@@ -255,8 +261,8 @@ class _MovieTabPageState extends State<MovieTabPage> {
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(color: const Color(0xFF1A1A1A), borderRadius: BorderRadius.circular(8)),
child: const Text('添加记录', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white)),
decoration: BoxDecoration(color: colors.primary, borderRadius: BorderRadius.circular(8)),
child: Text('添加记录', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onPrimary)),
),
),
],