fix(recommend): 修正推荐子页内容映射

This commit is contained in:
Zhou Weidong committed 2026-10-22 17:36:58 +08:00
1 parent af6b9bb3db
commit d06967c6ab
8 files changed
+128 -48

No files matched your search

+53 -9
View File
@@ -14,9 +14,9 @@ import '../../core/data/services/wallet_controller.dart';
import '../../core/navigation/fade_page_route.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/widgets/empty_state.dart';
import '../../l10n/app_localizations.dart';
import '../player/player_view.dart';
import '../ranking/ranking_page.dart';
import 'widgets/all_dramas_filter_grid.dart';
import 'widgets/recommend_sections_view.dart';
@@ -26,11 +26,13 @@ class RecommendPage extends StatefulWidget {
const RecommendPage({
super.key,
required this.feedController,
required this.active,
required this.onSearch,
required this.onOpenFilter,
});
final HomeFeedController feedController;
final bool active;
final VoidCallback onSearch;
final VoidCallback onOpenFilter;
@@ -57,13 +59,13 @@ class _RecommendPageState extends State<RecommendPage> {
child: IndexedStack(
index: _tab.index,
children: [
_recommendFeed(context),
RecommendSectionsView(
feedController: widget.feedController,
categories: categories,
onOpenDrama: _openDrama,
onMore: _handleMore,
),
const RankingPage(embedded: true),
AllDramasFilterGrid(
feedController: widget.feedController,
onOpenDrama: _openDrama,
@@ -78,6 +80,49 @@ class _RecommendPageState extends State<RecommendPage> {
);
}
Widget _recommendFeed(BuildContext context) {
final dramas = widget.feedController.dramas;
if (dramas.isEmpty) {
final l10n = AppLocalizations.of(context)!;
if (widget.feedController.loadingFirstPage) {
return const ColoredBox(
color: AppColors.mediaBlack,
child: Center(
child: CircularProgressIndicator(
key: Key('recommend-feed-loading'),
color: AppColors.muted,
),
),
);
}
return ColoredBox(
color: AppColors.mediaBlack,
child: EmptyState(
key: const Key('recommend-feed-empty'),
icon: Icons.movie_outlined,
title: l10n.noStories,
actionLabel: l10n.retry,
onAction: () => unawaited(widget.feedController.refreshCurrent()),
),
);
}
return PlayerPage(
key: const Key('recommend-feed-player'),
homeMode: true,
embedded: true,
active: widget.active && _tab == RecommendInnerTab.feed,
showHomeFeedHeader: false,
drama: dramas.first,
initialIndex: 0,
feedDramas: dramas,
feedChannel: widget.feedController.channel,
onOpenFullPlayer: (drama, episode) =>
_openDrama(drama, episodeId: episode.id),
onRefreshFeed: widget.feedController.refreshCurrent,
onLoadMore: widget.feedController.loadMore,
);
}
Widget _header(AppLocalizations l10n) {
final items = [
(RecommendInnerTab.feed, l10n.recommendTopTab, 'recommend'),
@@ -165,14 +210,10 @@ class _RecommendPageState extends State<RecommendPage> {
}
void _handleMore(RecommendSectionKind section) {
setState(() {
_tab = section == RecommendSectionKind.hits
? RecommendInnerTab.playlists
: RecommendInnerTab.allDramas;
});
setState(() => _tab = RecommendInnerTab.allDramas);
}
Future<void> _openDrama(Drama drama) async {
Future<void> _openDrama(Drama drama, {String? episodeId}) async {
final catalog = context.read<CatalogController>();
final wallet = context.read<WalletController>();
final downloads = context.read<DownloadController>();
@@ -183,11 +224,14 @@ class _RecommendPageState extends State<RecommendPage> {
// 卡片预览仍可直接进入播放器。
}
if (!mounted) return;
final episodeIndex = episodeId == null
? 0
: playable.episodes.indexWhere((episode) => episode.id == episodeId);
await Navigator.of(context).push<void>(
FadePageRoute(
builder: (_) => PlayerPage(
drama: playable,
initialIndex: 0,
initialIndex: episodeIndex < 0 ? 0 : episodeIndex,
homeMode: true,
feedDramas: [playable],
wallet: wallet,