fix: anim to top

This commit is contained in:
bggRGjQaUbCoE
2024-08-30 14:07:46 +08:00
parent d9eab8de47
commit ecefc4bdd5
9 changed files with 31 additions and 69 deletions

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.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';
@@ -62,13 +63,7 @@ class BangumiController extends GetxController {
} }
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }

View File

@@ -1,6 +1,7 @@
// ignore_for_file: avoid_print // ignore_for_file: avoid_print
import 'package:PiliPalaX/http/follow.dart'; import 'package:PiliPalaX/http/follow.dart';
import 'package:PiliPalaX/utils/extension.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -314,13 +315,6 @@ class DynamicsController extends GetxController
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() async {
tabsConfig[tabController.index]['ctr'].animateToTop(); tabsConfig[tabController.index]['ctr'].animateToTop();
if (!scrollController.hasClients) return; scrollController.animToTop();
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);
}
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -64,13 +65,7 @@ class DynamicsTabController extends GetxController {
} }
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:PiliPalaX/http/video.dart'; import 'package:PiliPalaX/http/video.dart';
@@ -48,13 +49,7 @@ class HotController extends GetxController {
} }
// 返回顶部 // 返回顶部
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.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';
@@ -50,13 +51,7 @@ class LiveController extends GetxController {
} }
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:PiliPalaX/http/video.dart'; import 'package:PiliPalaX/http/video.dart';
@@ -41,13 +42,7 @@ class ZoneController extends GetxController {
} }
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -97,13 +98,7 @@ class RcmdController extends GetxController {
} }
// 返回顶部 // 返回顶部
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/utils/extension.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:PiliPalaX/http/search.dart'; import 'package:PiliPalaX/http/search.dart';
@@ -42,14 +43,8 @@ class SearchPanelController extends GetxController {
} }
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() {
if (scrollController.offset >= scrollController.animToTop();
MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0);
} else {
await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
void onPushDetail(keyword, resultList) async { void onPushDetail(keyword, resultList) async {

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
extension ImageExtension on num { extension ImageExtension on num {
int cacheSize(BuildContext context) { int cacheSize(BuildContext context) {
@@ -8,10 +9,12 @@ extension ImageExtension on num {
extension ScrollControllerExt on ScrollController { extension ScrollControllerExt on ScrollController {
void animToTop() { void animToTop() {
animateTo( if (!hasClients) return;
0, if (offset >= MediaQuery.of(Get.context!).size.height * 5) {
duration: const Duration(milliseconds: 500), jumpTo(0);
curve: Curves.ease, } else {
); animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
} }
} }