opt: rank page

This commit is contained in:
bggRGjQaUbCoE
2024-09-08 13:24:55 +08:00
parent 35ca95230f
commit a74f0b55dd
2 changed files with 26 additions and 47 deletions

View File

@@ -79,199 +79,179 @@ List tabsConfig = [
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 0,
'label': '全站', 'label': '全站',
'type': RandType.all, 'type': RandType.all,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 0), tag: '0'),
'page': const ZonePage(rid: 0),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 168,
'label': '国创', 'label': '国创',
'type': RandType.creation, 'type': RandType.creation,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 168), tag: '168'),
'page': const ZonePage(rid: 168),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 1,
'label': '动画', 'label': '动画',
'type': RandType.animation, 'type': RandType.animation,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 1), tag: '1'),
'page': const ZonePage(rid: 1),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 3,
'label': '音乐', 'label': '音乐',
'type': RandType.music, 'type': RandType.music,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 3), tag: '3'),
'page': const ZonePage(rid: 3),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 129,
'label': '舞蹈', 'label': '舞蹈',
'type': RandType.dance, 'type': RandType.dance,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 129), tag: '129'),
'page': const ZonePage(rid: 129),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 4,
'label': '游戏', 'label': '游戏',
'type': RandType.game, 'type': RandType.game,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 4), tag: '4'),
'page': const ZonePage(rid: 4),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 36,
'label': '知识', 'label': '知识',
'type': RandType.knowledge, 'type': RandType.knowledge,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 36), tag: '36'),
'page': const ZonePage(rid: 36),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 188,
'label': '科技', 'label': '科技',
'type': RandType.technology, 'type': RandType.technology,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 188), tag: '188'),
'page': const ZonePage(rid: 188),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 234,
'label': '运动', 'label': '运动',
'type': RandType.sport, 'type': RandType.sport,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 234), tag: '234'),
'page': const ZonePage(rid: 234),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 223,
'label': '汽车', 'label': '汽车',
'type': RandType.car, 'type': RandType.car,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 223), tag: '223'),
'page': const ZonePage(rid: 223),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 160,
'label': '生活', 'label': '生活',
'type': RandType.life, 'type': RandType.life,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 160), tag: '160'),
'page': const ZonePage(rid: 160),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 211,
'label': '美食', 'label': '美食',
'type': RandType.food, 'type': RandType.food,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 211), tag: '211'),
'page': const ZonePage(rid: 211),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 217,
'label': '动物', 'label': '动物',
'type': RandType.animal, 'type': RandType.animal,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 217), tag: '217'),
'page': const ZonePage(rid: 217),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 119,
'label': '鬼畜', 'label': '鬼畜',
'type': RandType.madness, 'type': RandType.madness,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 119), tag: '119'),
'page': const ZonePage(rid: 119),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 155,
'label': '时尚', 'label': '时尚',
'type': RandType.fashion, 'type': RandType.fashion,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 155), tag: '155'),
'page': const ZonePage(rid: 155),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 5,
'label': '娱乐', 'label': '娱乐',
'type': RandType.entertainment, 'type': RandType.entertainment,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 5), tag: '5'),
'page': const ZonePage(rid: 5),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 181,
'label': '影视', 'label': '影视',
'type': RandType.film, 'type': RandType.film,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 181), tag: '181'),
'page': const ZonePage(rid: 181),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 177,
'label': '纪录', 'label': '纪录',
'type': RandType.documentary, 'type': RandType.documentary,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 177), tag: '177'),
'page': const ZonePage(rid: 177),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 23,
'label': '电影', 'label': '电影',
'type': RandType.movie, 'type': RandType.movie,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 23), tag: '23'),
'page': const ZonePage(rid: 23),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'rid': 11,
'label': '剧集', 'label': '剧集',
'type': RandType.teleplay, 'type': RandType.teleplay,
'ctr': Get.put<ZoneController>(ZoneController(zoneID: 11), tag: '11'),
'page': const ZonePage(rid: 11),
} }
]; ];

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/pages/rank/zone/index.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
@@ -9,7 +10,6 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
late RxList tabs = [].obs; late RxList tabs = [].obs;
RxInt initialIndex = 0.obs; RxInt initialIndex = 0.obs;
late TabController tabController; late TabController tabController;
late List tabsCtrList;
late List<Widget> tabsPageList; late List<Widget> tabsPageList;
Box setting = GStorage.setting; Box setting = GStorage.setting;
// late final StreamController<bool> searchBarStream = // late final StreamController<bool> searchBarStream =
@@ -27,21 +27,20 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
void onRefresh() { void onRefresh() {
int index = tabController.index; int index = tabController.index;
var ctr = tabsCtrList[index]; Get.find<ZoneController>(tag: tabsConfig[index]['rid'].toString())
ctr.onRefresh(); .onRefresh();
} }
void animateToTop() { void animateToTop() {
int index = tabController.index; int index = tabController.index;
var ctr = tabsCtrList[index]; Get.find<ZoneController>(tag: tabsConfig[index]['rid'].toString())
ctr.animateToTop(); .animateToTop();
} }
void setTabConfig() async { void setTabConfig() async {
tabs.value = tabsConfig; tabs.value = tabsConfig;
initialIndex.value = 0; initialIndex.value = 0;
tabsCtrList = tabs.map((e) => e['ctr']).toList(); tabsPageList = tabs.map((item) => ZonePage(rid: item['rid'])).toList();
tabsPageList = tabs.map<Widget>((e) => e['page']).toList();
tabController = TabController( tabController = TabController(
initialIndex: initialIndex.value, initialIndex: initialIndex.value,