opt rank type

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-16 17:49:20 +08:00
parent 35bc4a6ece
commit 1326cc4966
3 changed files with 36 additions and 101 deletions

View File

@@ -1,92 +1,28 @@
// TODO named record or enum enum RankType {
const List rankTabsConfig = [ all('全站', rid: 0),
{ anime('番剧', seasonType: 1),
'rid': 0, guochuang('国创', seasonType: 4),
'label': '全站', douga('动画', rid: 1005),
}, music('音乐', rid: 1003),
{ dance('舞蹈', rid: 1004),
'season_type': 1, game('游戏', rid: 1008),
'label': '番剧', knowledge('知识', rid: 1010),
}, tech('科技', rid: 1012),
{ sports('运动', rid: 1018),
// 'rid': 168, car('汽车', rid: 1013),
'season_type': 4, food('美食', rid: 1020),
'label': '国创', animal('动物', rid: 1024),
}, kichiku('鬼畜', rid: 1007),
{ fashion('时尚', rid: 1014),
'rid': 1005, //1, ent('娱乐', rid: 1002),
'label': '动画', cinephile('影视', rid: 1001),
}, documentary('记录', seasonType: 3),
{ movie('电影', seasonType: 2),
'rid': 1003, // 3, tv('剧集', seasonType: 5),
'label': '音乐', variety('综艺', seasonType: 7);
},
{ final String label;
'rid': 1004, // 129, final int? rid;
'label': '舞蹈', final int? seasonType;
}, const RankType(this.label, {this.rid, this.seasonType});
{ }
'rid': 1008, // 4,
'label': '游戏',
},
{
'rid': 1010, // 36,
'label': '知识',
},
{
'rid': 1012, // 188,
'label': '科技',
},
{
'rid': 1018, //234,
'label': '运动',
},
{
'rid': 1013, // 223,
'label': '汽车',
},
{
'rid': 1020, // 211,
'label': '美食',
},
{
'rid': 1024, //217,
'label': '动物',
},
{
'rid': 1007, // 119,
'label': '鬼畜',
},
{
'rid': 1014, // 155,
'label': '时尚',
},
{
'rid': 1002, // 5,
'label': '娱乐',
},
{
'rid': 1001, // 181,
'label': '影视',
},
{
// 'rid': 177,
'season_type': 3,
'label': '纪录',
},
{
// 'rid': 23,
'season_type': 2,
'label': '电影',
},
{
// 'rid': 11,
'season_type': 5,
'label': '剧集',
},
{
// 'rid': 11,
'season_type': 7,
'label': '综艺',
},
];

View File

@@ -12,9 +12,8 @@ class RankController extends GetxController
late TabController tabController; late TabController tabController;
ZoneController get controller { ZoneController get controller {
final item = rankTabsConfig[tabController.index]; final item = RankType.values[tabController.index];
return Get.find<ZoneController>( return Get.find<ZoneController>(tag: '${item.rid}${item.seasonType}');
tag: '${item['rid']}${item['season_type']}');
} }
@override @override
@@ -23,7 +22,7 @@ class RankController extends GetxController
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
tabController = TabController(length: rankTabsConfig.length, vsync: this); tabController = TabController(length: RankType.values.length, vsync: this);
} }
@override @override

View File

@@ -32,7 +32,7 @@ class _RankPageState extends State<RankPage>
), ),
child: Column( child: Column(
children: List.generate( children: List.generate(
rankTabsConfig.length, RankType.values.length,
(index) => Obx( (index) => Obx(
() => IntrinsicHeight( () => IntrinsicHeight(
child: InkWell( child: InkWell(
@@ -65,7 +65,7 @@ class _RankPageState extends State<RankPage>
padding: padding:
const EdgeInsets.symmetric(vertical: 7), const EdgeInsets.symmetric(vertical: 7),
child: Text( child: Text(
rankTabsConfig[index]['label'], RankType.values[index].label,
style: TextStyle( style: TextStyle(
color: color:
index == _rankController.tabIndex.value index == _rankController.tabIndex.value
@@ -92,10 +92,10 @@ class _RankPageState extends State<RankPage>
child: TabBarView( child: TabBarView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
controller: _rankController.tabController, controller: _rankController.tabController,
children: rankTabsConfig children: RankType.values
.map((item) => ZonePage( .map((item) => ZonePage(
rid: item['rid'], rid: item.rid,
seasonType: item['season_type'], seasonType: item.seasonType,
)) ))
.toList(), .toList(),
), ),