fix(recommend): 修正推荐子页内容映射
This commit is contained in:
1 parent
af6b9bb3db
commit
d06967c6ab
8 files changed
+128
-48
No files matched your search
@@ -296,6 +296,7 @@ class _HomeTabsState extends State<_HomeTabs> {
|
||||
Widget _recommend(BuildContext context) {
|
||||
return RecommendPage(
|
||||
feedController: widget.feedController,
|
||||
active: logic.tab == 1,
|
||||
onSearch: () => _openSearch(context),
|
||||
onOpenFilter: () => _pushPage(context, const FilterPage()),
|
||||
);
|
||||
@@ -323,9 +324,8 @@ class _HomeTabsState extends State<_HomeTabs> {
|
||||
|
||||
Future<void> _openWallet(BuildContext context) async {
|
||||
if (!await ensureSignedIn(context) || !context.mounted) return;
|
||||
await Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute(builder: (_) => const WalletPage()));
|
||||
await Navigator.of(context)
|
||||
.push<void>(MaterialPageRoute(builder: (_) => const WalletPage()));
|
||||
}
|
||||
|
||||
Widget _my(BuildContext context) {
|
||||
|
||||
@@ -66,6 +66,7 @@ class PlayerPage extends StatefulWidget {
|
||||
this.feedDramas,
|
||||
this.feedChannel,
|
||||
this.headerChannel,
|
||||
this.showHomeFeedHeader = true,
|
||||
this.onDramaChanged,
|
||||
this.onImmersiveChanged,
|
||||
this.onOpenFullPlayer,
|
||||
@@ -90,6 +91,7 @@ class PlayerPage extends StatefulWidget {
|
||||
final List<Drama>? feedDramas;
|
||||
final HomeFeedChannel? feedChannel;
|
||||
final HomeFeedChannel? headerChannel;
|
||||
final bool showHomeFeedHeader;
|
||||
final ValueChanged<Drama>? onDramaChanged;
|
||||
final ValueChanged<bool>? onImmersiveChanged;
|
||||
final Future<void> Function(Drama drama, Episode episode)? onOpenFullPlayer;
|
||||
@@ -360,7 +362,11 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
content,
|
||||
if (widget.homeMode && !_boosting && !logic.pip && !logic.pipPreparing)
|
||||
if (widget.homeMode &&
|
||||
widget.showHomeFeedHeader &&
|
||||
!_boosting &&
|
||||
!logic.pip &&
|
||||
!logic.pipPreparing)
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user