新增影视时长优化界面

This commit is contained in:
DelLevin-Home
2026-08-09 13:32:08 +08:00
parent 7af892c760
commit 26ec55dc9b
7 changed files with 403 additions and 150 deletions

View File

@@ -263,6 +263,11 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
Text('已观看 ${movie.watchCount}',
style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.4))),
],
if (movie.duration > 0) ...[
const SizedBox(height: 4),
Text(_formatDuration(movie.duration),
style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.4))),
],
Divider(height: 32, thickness: 0.5, color: colors.outline),
// 详细信息
if (movie.directors.isNotEmpty) _buildDesktopInfoRow('导演', movie.directors.join(''), colors),
@@ -1523,6 +1528,14 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
color: colors.onSurface.withValues(alpha: 0.4),
),
),
if (movie.duration > 0)
Text(
_formatDuration(movie.duration),
style: TextStyle(
fontSize: 14,
color: colors.onSurface.withValues(alpha: 0.4),
),
),
],
),
);
@@ -2070,6 +2083,16 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
return '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
}
/// 格式化时长120 -> "2小时0分"0 -> ""
String _formatDuration(int minutes) {
if (minutes <= 0) return '';
final h = minutes ~/ 60;
final m = minutes % 60;
if (h > 0 && m > 0) return '时长 $h小时$m分';
if (h > 0) return '时长 $h小时';
return '时长 $m分';
}
void _navigateToEdit(BuildContext context) {
final provider = context.read<AppProvider>();
Navigator.pushNamed(context, '/movie-form', arguments: widget.movie).then((_) {