fix: zoneController error
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/common/rank_type.dart';
|
||||
import 'package:pilipala/pages/rank/zone/index.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class RankController extends GetxController with GetTickerProviderStateMixin {
|
||||
@ -29,20 +30,22 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
void onRefresh() {
|
||||
int index = tabController.index;
|
||||
var ctr = tabsCtrList[index];
|
||||
ctr().onRefresh();
|
||||
final ZoneController ctr = tabsCtrList[index];
|
||||
ctr.onRefresh();
|
||||
}
|
||||
|
||||
void animateToTop() {
|
||||
int index = tabController.index;
|
||||
var ctr = tabsCtrList[index];
|
||||
ctr().animateToTop();
|
||||
final ZoneController ctr = tabsCtrList[index];
|
||||
ctr.animateToTop();
|
||||
}
|
||||
|
||||
void setTabConfig() async {
|
||||
tabs.value = tabsConfig;
|
||||
initialIndex.value = 0;
|
||||
tabsCtrList = tabs.map((e) => e['ctr']).toList();
|
||||
tabsCtrList = tabs
|
||||
.map((e) => Get.put(ZoneController(), tag: e['rid'].toString()))
|
||||
.toList();
|
||||
tabsPageList = tabs.map<Widget>((e) => e['page']).toList();
|
||||
|
||||
tabController = TabController(
|
||||
|
@ -102,7 +102,7 @@ class _RankPageState extends State<RankPage>
|
||||
onTap: (value) {
|
||||
feedBack();
|
||||
if (_rankController.initialIndex.value == value) {
|
||||
_rankController.tabsCtrList[value]().animateToTop();
|
||||
_rankController.tabsCtrList[value].animateToTop();
|
||||
}
|
||||
_rankController.initialIndex.value = value;
|
||||
},
|
||||
|
@ -42,12 +42,15 @@ class ZoneController extends GetxController {
|
||||
|
||||
// 返回顶部并刷新
|
||||
void animateToTop() async {
|
||||
if (scrollController.offset >=
|
||||
MediaQuery.of(Get.context!).size.height * 5) {
|
||||
scrollController.jumpTo(0);
|
||||
} else {
|
||||
await scrollController.animateTo(0,
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
if (scrollController.hasClients) {
|
||||
if (scrollController.offset >=
|
||||
MediaQuery.of(Get.context!).size.height * 5) {
|
||||
scrollController.jumpTo(0);
|
||||
} else {
|
||||
await scrollController.animateTo(0,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user