generated from dellevin/template
服务端接口优化
todo:待添加影评海报,书评书摘的接口与标签接口
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:cross_file/cross_file.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@@ -193,10 +194,9 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
|
||||
Widget _buildPosterSection(Movie movie) {
|
||||
return SizedBox.expand(
|
||||
child: movie.posterPath != null && movie.posterPath!.isNotEmpty
|
||||
? Image.file(
|
||||
File(movie.posterPath!),
|
||||
? FadeInLocalImage(
|
||||
path: movie.posterPath,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildPosterPlaceholder(),
|
||||
)
|
||||
: _buildPosterPlaceholder(),
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
import '../../utils/image_path_helper.dart';
|
||||
@@ -1381,10 +1382,9 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: hasPoster
|
||||
? Image.file(
|
||||
File(_posterPath!),
|
||||
? FadeInLocalImage(
|
||||
path: _posterPath,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildCoverPlaceholder(),
|
||||
)
|
||||
: _buildCoverPlaceholder(),
|
||||
),
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
import '../../utils/image_path_helper.dart';
|
||||
@@ -158,15 +159,9 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 海报图片
|
||||
Image.file(
|
||||
File(poster.posterPath),
|
||||
FadeInLocalImage(
|
||||
path: poster.posterPath,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => Center(
|
||||
child: Icon(
|
||||
Icons.broken_image,
|
||||
color: colors.onSurface.withValues(alpha: 0.25),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 渐变遮罩(底部)
|
||||
Positioned(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
import 'movie_review_form_page.dart';
|
||||
|
||||
/// 影评详情页
|
||||
@@ -121,7 +122,8 @@ class _MovieReviewDetailPageState extends State<MovieReviewDetailPage> {
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(6), color: colors.surfaceContainerHighest),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: movie.posterPath != null
|
||||
? Image.file(File(movie.posterPath!), fit: BoxFit.cover, errorBuilder: (_, __, ___) => Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
? FadeInLocalImage(path: movie.posterPath, fit: BoxFit.cover,
|
||||
errorWidget: 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),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
|
||||
@@ -155,8 +156,8 @@ class _MovieReviewFormPageState extends State<MovieReviewFormPage> {
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: movie.posterPath != null
|
||||
? Image.file(File(movie.posterPath!), fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
? FadeInLocalImage(path: movie.posterPath, fit: BoxFit.cover,
|
||||
errorWidget: Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
: Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:path_provider/path_provider.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../utils/toast_util.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
|
||||
/// 影视分享海报页面
|
||||
class MovieSharePage extends StatefulWidget {
|
||||
@@ -103,8 +104,8 @@ class _MovieSharePageState extends State<MovieSharePage> {
|
||||
if (hasPoster)
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
|
||||
child: Image.file(
|
||||
File(movie.posterPath!),
|
||||
child: FadeInLocalImage(
|
||||
path: movie.posterPath,
|
||||
width: 320,
|
||||
height: 200,
|
||||
fit: BoxFit.cover,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../utils/user_prefs.dart';
|
||||
import '../../widgets/movie_status_bar.dart';
|
||||
import '../../widgets/movie_list_item.dart';
|
||||
import '../../widgets/animated_star_rating.dart';
|
||||
import '../../widgets/shimmer_skeleton.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
|
||||
/// 观影标签页
|
||||
/// 观影标签页(分页 + 触底加载)
|
||||
class MovieTabPage extends StatefulWidget {
|
||||
const MovieTabPage({super.key});
|
||||
|
||||
@@ -18,17 +19,98 @@ class MovieTabPage extends StatefulWidget {
|
||||
|
||||
class _MovieTabPageState extends State<MovieTabPage> {
|
||||
int _layoutStyle = 0;
|
||||
bool _firstLoad = true;
|
||||
final List<Movie> _items = [];
|
||||
bool _hasMore = true;
|
||||
bool _isLoading = false;
|
||||
int _offset = 0;
|
||||
int _lastStatusIndex = -1;
|
||||
bool _initialized = false;
|
||||
int _lastDataCount = -1;
|
||||
DateTime? _lastUpdatedAt;
|
||||
late ScrollController _scrollController;
|
||||
|
||||
static const _statusMap = {0: 'watched', 1: 'watching', 2: 'want_to_watch'};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_layoutStyle = UserPrefs().movieLayoutStyle;
|
||||
_scrollController = ScrollController()..addListener(_onScroll);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) setState(() => _firstLoad = false);
|
||||
final provider = context.read<AppProvider>();
|
||||
provider.addListener(_onDataChanged);
|
||||
_lastDataCount = provider.movies.length;
|
||||
if (provider.movies.isNotEmpty) _lastUpdatedAt = provider.movies.first.updatedAt;
|
||||
_loadFirst();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onDataChanged() {
|
||||
if (!_initialized || !mounted) return;
|
||||
final provider = context.read<AppProvider>();
|
||||
final count = provider.movies.length;
|
||||
final latest = provider.movies.isNotEmpty ? provider.movies.first.updatedAt : null;
|
||||
if (count != _lastDataCount || latest != _lastUpdatedAt) {
|
||||
_lastDataCount = count;
|
||||
_lastUpdatedAt = latest;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) _loadFirst();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _onScroll() {
|
||||
if (_scrollController.position.pixels >= _scrollController.position.maxScrollExtent - 200) {
|
||||
_loadMore();
|
||||
}
|
||||
}
|
||||
|
||||
String get _currentStatus => _statusMap[context.read<AppProvider>().movieStatusIndex] ?? 'watched';
|
||||
|
||||
Future<void> _loadFirst() async {
|
||||
final provider = context.read<AppProvider>();
|
||||
final statusIdx = provider.movieStatusIndex;
|
||||
_lastStatusIndex = statusIdx;
|
||||
_initialized = true;
|
||||
final status = _statusMap[statusIdx] ?? 'watched';
|
||||
setState(() { _isLoading = true; _items.clear(); _offset = 0; _hasMore = true; });
|
||||
final list = await provider.loadMoviesPaged(status: status, offset: 0);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_items.addAll(list);
|
||||
_offset = list.length;
|
||||
_hasMore = list.length >= 20;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadMore() async {
|
||||
if (_isLoading || !_hasMore) return;
|
||||
setState(() => _isLoading = true);
|
||||
final provider = context.read<AppProvider>();
|
||||
final status = _statusMap[provider.movieStatusIndex] ?? 'watched';
|
||||
final list = await provider.loadMoviesPaged(status: status, offset: _offset);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_items.addAll(list);
|
||||
_offset += list.length;
|
||||
_hasMore = list.length >= 20;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _refresh() async {
|
||||
final provider = context.read<AppProvider>();
|
||||
await provider.loadMovies();
|
||||
await _loadFirst();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
@@ -36,30 +118,26 @@ class _MovieTabPageState extends State<MovieTabPage> {
|
||||
children: [
|
||||
const MovieStatusBar(),
|
||||
Divider(height: 0.5, thickness: 0.5, color: colors.outline),
|
||||
Expanded(
|
||||
child: _buildMovieList(context),
|
||||
),
|
||||
Expanded(child: _buildBody(context)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMovieList(BuildContext context) {
|
||||
Widget _buildBody(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();
|
||||
builder: (context, provider, _) {
|
||||
// 状态切换时重新加载(跳过首次未初始化的情况)
|
||||
if (_initialized && provider.movieStatusIndex != _lastStatusIndex) {
|
||||
_lastStatusIndex = provider.movieStatusIndex;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _loadFirst());
|
||||
}
|
||||
_firstLoad = false;
|
||||
|
||||
final movies = provider.getMoviesByStatus(currentStatus);
|
||||
if (_items.isEmpty && _isLoading) return _buildSkeleton();
|
||||
|
||||
if (movies.isEmpty) {
|
||||
if (_items.isEmpty) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => await provider.loadMovies(),
|
||||
onRefresh: _refresh,
|
||||
color: colors.primary,
|
||||
backgroundColor: colors.surface,
|
||||
child: ListView(
|
||||
@@ -69,49 +147,55 @@ class _MovieTabPageState extends State<MovieTabPage> {
|
||||
);
|
||||
}
|
||||
|
||||
if (_layoutStyle == 1) {
|
||||
return _buildListView(movies, provider);
|
||||
}
|
||||
return _buildGridView(movies, provider);
|
||||
return RefreshIndicator(
|
||||
onRefresh: _refresh,
|
||||
color: colors.primary,
|
||||
backgroundColor: colors.surface,
|
||||
child: _layoutStyle == 1 ? _buildListView() : _buildGridView(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGridView(List movies, AppProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => await provider.loadMovies(),
|
||||
color: colors.primary,
|
||||
backgroundColor: colors.surface,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 100),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
childAspectRatio: 0.55,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 16,
|
||||
),
|
||||
itemCount: movies.length,
|
||||
itemBuilder: (context, index) => MovieListItem(movie: movies[index]),
|
||||
Widget _buildGridView() {
|
||||
return GridView.builder(
|
||||
controller: _scrollController,
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 100),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3, childAspectRatio: 0.55, crossAxisSpacing: 12, mainAxisSpacing: 16,
|
||||
),
|
||||
itemCount: _items.length + (_hasMore ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (index >= _items.length) return _buildLoadMoreIndicator();
|
||||
return MovieListItem(movie: _items[index]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListView() {
|
||||
return ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
|
||||
itemCount: _items.length + (_hasMore ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (index >= _items.length) return _buildLoadMoreIndicator();
|
||||
return _buildListCard(_items[index]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadMoreIndicator() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: Center(
|
||||
child: _isLoading
|
||||
? SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2, color: Theme.of(context).colorScheme.primary))
|
||||
: Text('没有更多了', style: TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.3))),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListView(List movies, AppProvider provider) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => await provider.loadMovies(),
|
||||
color: colors.primary,
|
||||
backgroundColor: colors.surface,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
|
||||
itemCount: movies.length,
|
||||
itemBuilder: (context, index) => _buildListCard(movies[index]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListCard(movie) {
|
||||
Widget _buildListCard(Movie movie) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.pushNamed(context, '/movie-detail', arguments: movie),
|
||||
@@ -119,78 +203,59 @@ class _MovieTabPageState extends State<MovieTabPage> {
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 48, height: 64,
|
||||
decoration: BoxDecoration(
|
||||
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: (_, __, ___) => Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
: Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(movie.title, maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
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: TextStyle(fontSize: 12, color: colors.onSurface.withValues(alpha: 0.35))),
|
||||
],
|
||||
const SizedBox(height: 6),
|
||||
if (movie.rating != null)
|
||||
AnimatedStarRating(rating: movie.rating!, starSize: 12, showNumber: true)
|
||||
else
|
||||
const SizedBox(height: 14),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Icon(Icons.chevron_right, color: colors.onSurface.withValues(alpha: 0.2), size: 20),
|
||||
],
|
||||
),
|
||||
decoration: BoxDecoration(color: colors.surfaceContainerHigh, borderRadius: BorderRadius.circular(12)),
|
||||
child: Row(children: [
|
||||
Container(
|
||||
width: 48, height: 64,
|
||||
decoration: BoxDecoration(color: colors.outlineVariant, borderRadius: BorderRadius.circular(6)),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: movie.posterPath != null && movie.posterPath!.isNotEmpty
|
||||
? FadeInLocalImage(path: movie.posterPath, fit: BoxFit.cover,
|
||||
errorWidget: Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)))
|
||||
: Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(movie.title, maxLines: 1, overflow: TextOverflow.ellipsis,
|
||||
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: TextStyle(fontSize: 12, color: colors.onSurface.withValues(alpha: 0.35))),
|
||||
],
|
||||
const SizedBox(height: 6),
|
||||
if (movie.rating != null) AnimatedStarRating(rating: movie.rating!, starSize: 12, showNumber: true)
|
||||
else const SizedBox(height: 14),
|
||||
])),
|
||||
const SizedBox(width: 8),
|
||||
Icon(Icons.chevron_right, color: colors.onSurface.withValues(alpha: 0.2), size: 20),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(BuildContext context, movie) {
|
||||
void _showDeleteDialog(BuildContext context, Movie movie) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: colors.surface,
|
||||
elevation: 0,
|
||||
backgroundColor: colors.surface, elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)),
|
||||
content: Text('确定要删除《${movie.title}》吗?删除后可在回收站恢复。',
|
||||
style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.6), height: 1.5)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
),
|
||||
TextButton(onPressed: () => Navigator.pop(ctx),
|
||||
child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.6)))),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await context.read<AppProvider>().removeMovie(movie.id);
|
||||
Navigator.pop(ctx);
|
||||
_loadFirst();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: colors.error, foregroundColor: colors.onError, elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: colors.error, foregroundColor: colors.onError, elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8)),
|
||||
child: const Text('删除'),
|
||||
),
|
||||
],
|
||||
@@ -199,42 +264,24 @@ class _MovieTabPageState extends State<MovieTabPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSkeleton() {
|
||||
return _layoutStyle == 1 ? _buildListSkeleton() : const MovieSkeletonGrid();
|
||||
}
|
||||
Widget _buildSkeleton() => _layoutStyle == 1 ? _buildListSkeleton() : const MovieSkeletonGrid();
|
||||
|
||||
Widget _buildListSkeleton() {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
|
||||
itemCount: 6,
|
||||
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100), itemCount: 6,
|
||||
itemBuilder: (_, __) => Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
ShimmerSkeleton(width: 48, height: 64, borderRadius: 6),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ShimmerSkeleton(width: 160, height: 16),
|
||||
SizedBox(height: 6),
|
||||
ShimmerSkeleton(width: 100, height: 12),
|
||||
SizedBox(height: 6),
|
||||
ShimmerSkeleton(width: 70, height: 12),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
ShimmerSkeleton(width: 20, height: 20, borderRadius: 10),
|
||||
],
|
||||
),
|
||||
margin: const EdgeInsets.only(bottom: 8), padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(color: colors.surfaceContainerHigh, borderRadius: BorderRadius.circular(12)),
|
||||
child: const Row(children: [
|
||||
ShimmerSkeleton(width: 48, height: 64, borderRadius: 6), SizedBox(width: 12),
|
||||
Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
ShimmerSkeleton(width: 160, height: 16), SizedBox(height: 6),
|
||||
ShimmerSkeleton(width: 100, height: 12), SizedBox(height: 6),
|
||||
ShimmerSkeleton(width: 70, height: 12),
|
||||
])),
|
||||
SizedBox(width: 8), ShimmerSkeleton(width: 20, height: 20, borderRadius: 10),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -242,31 +289,24 @@ class _MovieTabPageState extends State<MovieTabPage> {
|
||||
Widget _buildEmptyState(BuildContext context, int statusIndex) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final statusText = ['已看', '在看', '想看'][statusIndex];
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 80, height: 80,
|
||||
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: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))),
|
||||
const SizedBox(height: 24),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
final statusMap = {0: 'watched', 1: 'watching', 2: 'want_to_watch'};
|
||||
Navigator.pushNamed(context, '/movie-form', arguments: {'initialStatus': statusMap[statusIndex]!});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(color: colors.primary, borderRadius: BorderRadius.circular(8)),
|
||||
child: Text('添加记录', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onPrimary)),
|
||||
),
|
||||
),
|
||||
],
|
||||
return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Container(width: 80, height: 80,
|
||||
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: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))),
|
||||
const SizedBox(height: 24),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
final statusMap = {0: 'watched', 1: 'watching', 2: 'want_to_watch'};
|
||||
Navigator.pushNamed(context, '/movie-form', arguments: {'initialStatus': statusMap[statusIndex]!});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(color: colors.primary, borderRadius: BorderRadius.circular(8)),
|
||||
child: Text('添加记录', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onPrimary)),
|
||||
),
|
||||
),
|
||||
);
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../models/data_models.dart';
|
||||
import '../../widgets/fade_in_local_image.dart';
|
||||
|
||||
/// 海报画廊页面 - 支持左右滑动浏览
|
||||
class PosterGalleryPage extends StatefulWidget {
|
||||
@@ -53,16 +54,9 @@ class _PosterGalleryPageState extends State<PosterGalleryPage> {
|
||||
minScale: 0.5,
|
||||
maxScale: 3.0,
|
||||
child: Center(
|
||||
child: Image.file(
|
||||
File(poster.posterPath),
|
||||
child: FadeInLocalImage(
|
||||
path: poster.posterPath,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (_, __, ___) => const Center(
|
||||
child: Icon(
|
||||
Icons.broken_image,
|
||||
color: Colors.white54,
|
||||
size: 64,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user