mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-18 17:46:52 +08:00
@@ -7,41 +7,19 @@ import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/models/common/rank_type.dart';
|
||||
|
||||
class RankController extends GetxController
|
||||
with GetTickerProviderStateMixin, ScrollOrRefreshMixin {
|
||||
bool flag = false;
|
||||
late RxList tabs = [].obs;
|
||||
RxInt initialIndex = 0.obs;
|
||||
with GetSingleTickerProviderStateMixin, ScrollOrRefreshMixin {
|
||||
RxInt tabIndex = 0.obs;
|
||||
late TabController tabController;
|
||||
late List<Widget> tabsPageList;
|
||||
// late final StreamController<bool> searchBarStream =
|
||||
// StreamController<bool>.broadcast();
|
||||
late bool enableGradientBg;
|
||||
|
||||
ZoneController get controller => Get.find<ZoneController>(
|
||||
tag: tabsConfig[tabController.index]['rid'].toString());
|
||||
|
||||
@override
|
||||
ScrollController get scrollController => controller.scrollController;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// enableGradientBg =
|
||||
// setting.get(SettingBoxKey.enableGradientBg, defaultValue: true);
|
||||
// 进行tabs配置
|
||||
setTabConfig();
|
||||
}
|
||||
|
||||
void setTabConfig() async {
|
||||
tabs.value = tabsConfig;
|
||||
initialIndex.value = 0;
|
||||
tabsPageList = tabs.map((item) => ZonePage(rid: item['rid'])).toList();
|
||||
|
||||
tabController = TabController(
|
||||
initialIndex: initialIndex.value,
|
||||
length: tabs.length,
|
||||
vsync: this,
|
||||
);
|
||||
tabController = TabController(length: tabsConfig.length, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:PiliPlus/models/common/rank_type.dart';
|
||||
import 'package:PiliPlus/pages/rank/zone/view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import './controller.dart';
|
||||
@@ -10,19 +12,12 @@ class RankPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RankPageState extends State<RankPage>
|
||||
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final RankController _rankController = Get.put(RankController());
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_rankController.tabController =
|
||||
TabController(vsync: this, length: _rankController.tabs.length);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
@@ -36,16 +31,16 @@ class _RankPageState extends State<RankPage>
|
||||
),
|
||||
child: Column(
|
||||
children: List.generate(
|
||||
_rankController.tabs.length,
|
||||
tabsConfig.length,
|
||||
(index) => Obx(
|
||||
() => IntrinsicHeight(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
_rankController.initialIndex.value = index;
|
||||
_rankController.tabIndex.value = index;
|
||||
_rankController.tabController.animateTo(index);
|
||||
},
|
||||
child: ColoredBox(
|
||||
color: index == _rankController.initialIndex.value
|
||||
color: index == _rankController.tabIndex.value
|
||||
? Theme.of(context).colorScheme.onInverseSurface
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
child: Row(
|
||||
@@ -54,7 +49,7 @@ class _RankPageState extends State<RankPage>
|
||||
Container(
|
||||
height: double.infinity,
|
||||
width: 3,
|
||||
color: index == _rankController.initialIndex.value
|
||||
color: index == _rankController.tabIndex.value
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent,
|
||||
),
|
||||
@@ -65,10 +60,10 @@ class _RankPageState extends State<RankPage>
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 7),
|
||||
child: Text(
|
||||
_rankController.tabs[index]['label'],
|
||||
tabsConfig[index]['label'],
|
||||
style: TextStyle(
|
||||
color: index ==
|
||||
_rankController.initialIndex.value
|
||||
_rankController.tabIndex.value
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
@@ -94,7 +89,8 @@ class _RankPageState extends State<RankPage>
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _rankController.tabController,
|
||||
children: _rankController.tabsPageList,
|
||||
children:
|
||||
tabsConfig.map((item) => ZonePage(rid: item['rid'])).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -43,7 +43,6 @@ class _ZonePageState extends CommonPageState<ZonePage, ZoneController>
|
||||
controller: controller.scrollController,
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
// 单列布局 EdgeInsets.zero
|
||||
padding: EdgeInsets.only(
|
||||
top: StyleString.safeSpace - 5,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
|
||||
Reference in New Issue
Block a user