feat(ranking): 榜单改为统一行布局
This commit is contained in:
1 parent
7f65fe4d48
commit
8c1662475a
16 files changed
+927
-390
No files matched your search
@@ -10,11 +10,13 @@ import '../../core/data/models/home_feed.dart';
|
||||
import '../../core/data/remote/catalog_api.dart';
|
||||
import '../../core/data/services/category_controller.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
import '../../core/theme/app_dimens.dart';
|
||||
import '../../core/widgets/app_pull_to_refresh.dart';
|
||||
import '../../core/widgets/empty_state.dart';
|
||||
import '../../core/widgets/paged_list_footer.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import '../player/open_player.dart';
|
||||
import '../home/widgets/home_ranking_dramas.dart';
|
||||
import 'widgets/home_hero_carousel.dart';
|
||||
import 'widgets/home_recommend_content.dart';
|
||||
import 'widgets/recommend_channel_nav.dart';
|
||||
@@ -100,6 +102,21 @@ class _RecommendDiscoverPageState extends State<RecommendDiscoverPage>
|
||||
if (_requestedCategories.contains(id)) return;
|
||||
_requestedCategories.add(id);
|
||||
final categories = context.read<CategoryController>();
|
||||
final category = categories.categories
|
||||
.where((item) => item.id == id)
|
||||
.firstOrNull;
|
||||
if (category?.isRanking ?? false) {
|
||||
final slot = categories.rankingSlotOf(id);
|
||||
if (categories.rankingLoader == null ||
|
||||
slot.ranking != null ||
|
||||
slot.loading) {
|
||||
return;
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) unawaited(categories.openRanking(id));
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (categories.dramaPageLoader == null) return;
|
||||
final slot = categories.slotOf(id);
|
||||
if (slot.dramas.isNotEmpty || slot.loading) return;
|
||||
@@ -171,6 +188,16 @@ class _RecommendDiscoverPageState extends State<RecommendDiscoverPage>
|
||||
onPageChanged: (i) => _onPageChanged(i, orderedIds),
|
||||
itemBuilder: (context, index) {
|
||||
final category = categoryList[index];
|
||||
if (category.isRanking) {
|
||||
return HomeRankingDramas(
|
||||
key: PageStorageKey<String>(
|
||||
'recommend-ranking-${category.id}',
|
||||
),
|
||||
categoryId: category.id,
|
||||
topPadding: mediaTop + RecommendChannelNav.height,
|
||||
onOpenDrama: _openDrama,
|
||||
);
|
||||
}
|
||||
return _ChannelFeed(
|
||||
key: PageStorageKey<String>(
|
||||
'recommend-channel-${category.id}',
|
||||
@@ -318,21 +345,14 @@ class _ChannelFeedState extends State<_ChannelFeed>
|
||||
sliverList.add(
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: showCarousel
|
||||
? 0
|
||||
: widget.mediaTop + RecommendChannelNav.height,
|
||||
),
|
||||
child: Center(child: _placeholder(slot.loading)),
|
||||
),
|
||||
child: Center(child: _placeholder(slot.loading)),
|
||||
),
|
||||
);
|
||||
} else if (widget.isFeatured) {
|
||||
// 无轮播图时内容需避开顶部悬浮导航。
|
||||
final contentTop = showCarousel
|
||||
? 24.0
|
||||
: widget.mediaTop + RecommendChannelNav.height + 16;
|
||||
: widget.mediaTop + RecommendChannelNav.height + AppDimens.spaceSm;
|
||||
if (newArrivals.isNotEmpty) {
|
||||
sliverList.add(SliverToBoxAdapter(child: SizedBox(height: contentTop)));
|
||||
sliverList.add(
|
||||
@@ -358,7 +378,9 @@ class _ChannelFeedState extends State<_ChannelFeed>
|
||||
dramas,
|
||||
topPadding: showCarousel
|
||||
? 20
|
||||
: widget.mediaTop + RecommendChannelNav.height + 16,
|
||||
: widget.mediaTop +
|
||||
RecommendChannelNav.height +
|
||||
AppDimens.spaceSm,
|
||||
crossAxisCount: 3,
|
||||
),
|
||||
);
|
||||
@@ -411,6 +433,8 @@ class _ChannelFeedState extends State<_ChannelFeed>
|
||||
key: const Key('recommend-category-empty'),
|
||||
icon: Icons.movie_outlined,
|
||||
title: l10n.noStories,
|
||||
compact: true,
|
||||
stretchContent: true,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user