fix: member contribute page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-16 19:49:39 +08:00
parent 7043fdc35d
commit 980733ba22
2 changed files with 61 additions and 75 deletions

View File

@@ -77,57 +77,54 @@ class _MemberContributeState extends State<MemberContribute>
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _controller.tabController,
children: _controller.items!
.map(
(item) => switch (item.param) {
'video' => MemberVideo(
type: ContributeType.video,
heroTag: widget.heroTag,
mid: widget.mid,
title: item.title,
),
'charging_video' => MemberVideo(
type: ContributeType.charging,
heroTag: widget.heroTag,
mid: widget.mid,
title: item.title,
),
'article' => MemberArticle(
heroTag: widget.heroTag,
mid: widget.mid,
),
'audio' => MemberAudio(heroTag: widget.heroTag),
'season_video' => MemberVideo(
type: ContributeType.season,
heroTag: widget.heroTag,
mid: widget.mid,
seasonId: item.seasonId,
title: item.title,
),
'series' => MemberVideo(
type: ContributeType.series,
heroTag: widget.heroTag,
mid: widget.mid,
seriesId: item.seriesId,
title: item.title,
),
'ugcSeason' => SeasonSeriesPage(
mid: widget.mid,
heroTag: widget.heroTag,
),
_ => Center(child: Text(item.title!))
},
)
.toList(),
children: _controller.items!.map(_getPageFromType).toList(),
),
),
],
)
: MemberVideo(
type: ContributeType.video,
heroTag: widget.heroTag,
mid: widget.mid,
title: '视频',
);
: _controller.items?.isNotEmpty == true
? _getPageFromType(_controller.items!.first)
: const SizedBox.shrink();
}
Widget _getPageFromType(item) {
return switch (item.param) {
'video' => MemberVideo(
type: ContributeType.video,
heroTag: widget.heroTag,
mid: widget.mid,
title: item.title,
),
'charging_video' => MemberVideo(
type: ContributeType.charging,
heroTag: widget.heroTag,
mid: widget.mid,
title: item.title,
),
'article' => MemberArticle(
heroTag: widget.heroTag,
mid: widget.mid,
),
'audio' => MemberAudio(heroTag: widget.heroTag),
'season_video' => MemberVideo(
type: ContributeType.season,
heroTag: widget.heroTag,
mid: widget.mid,
seasonId: item.seasonId,
title: item.title,
),
'series' => MemberVideo(
type: ContributeType.series,
heroTag: widget.heroTag,
mid: widget.mid,
seriesId: item.seriesId,
title: item.title,
),
'ugcSeason' => SeasonSeriesPage(
mid: widget.mid,
heroTag: widget.heroTag,
),
_ => Center(child: Text(item.title!))
};
}
}

View File

@@ -29,36 +29,25 @@ class MemberContributeCtr extends CommonController
super.onInit();
Tab2 contribute =
_ctr.tab2!.firstWhere((item) => item.param == 'contribute');
if (contribute.items?.isNullOrEmpty == false &&
contribute.items!.length > 1) {
if (contribute.items?.isNullOrEmpty == false) {
items = contribute.items;
// if (_ctr.ugcSeasonCount != null) {
// int currentSeasonCount =
// items!.where((item) => item.param == 'season_video').length;
// if (currentSeasonCount < _ctr.ugcSeasonCount!) {
// items!.add(
// Item(
// param: 'ugcSeason',
// title: '全部合集/列表',
// ),
// );
// }
// }
// show if exist
if (_ctr.hasSeasonOrSeries == true) {
items!.add(
Item(
param: 'ugcSeason',
title: '全部合集/列表',
),
if (contribute.items!.length > 1) {
// show if exist
if (_ctr.hasSeasonOrSeries == true) {
items!.add(
Item(
param: 'ugcSeason',
title: '全部合集/列表',
),
);
}
tabs = items!.map((item) => Tab(text: item.title)).toList();
tabController = TabController(
vsync: this,
length: items!.length,
initialIndex: max(0, initialIndex ?? 0),
);
}
tabs = items!.map((item) => Tab(text: item.title)).toList();
tabController = TabController(
vsync: this,
length: items!.length,
initialIndex: max(0, initialIndex ?? 0),
);
}
}