mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -12,19 +11,6 @@ abstract mixin class ScrollOrRefreshMixin {
|
||||
void animateToTop() => scrollController.animToTop();
|
||||
|
||||
Future<void> onRefresh();
|
||||
|
||||
void toTopOrRefresh() {
|
||||
if (scrollController.hasClients) {
|
||||
if (scrollController.position.pixels == 0) {
|
||||
EasyThrottle.throttle('topOrRefresh', const Duration(milliseconds: 500),
|
||||
() {
|
||||
onRefresh();
|
||||
});
|
||||
} else {
|
||||
animateToTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CommonController<R, T> extends GetxController
|
||||
|
||||
@@ -188,21 +188,6 @@ class DynamicsController extends GetxController
|
||||
scrollController.animToTop();
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<void> toTopOrRefresh() {
|
||||
final ctr = controller;
|
||||
if (scrollController.hasClients && ctr.scrollController.hasClients) {
|
||||
if (scrollController.position.pixels == 0 &&
|
||||
ctr.scrollController.position.pixels == 0) {
|
||||
return onRefresh();
|
||||
} else {
|
||||
animateToTop();
|
||||
}
|
||||
} else {
|
||||
super.toTopOrRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
tabController.dispose();
|
||||
|
||||
@@ -152,9 +152,9 @@ class _MainAppState extends State<MainApp>
|
||||
});
|
||||
} else {
|
||||
if (currentPage is HomePage) {
|
||||
_homeController.toTopOrRefresh();
|
||||
_homeController.animateToTop();
|
||||
} else if (currentPage is DynamicsPage) {
|
||||
_dynamicController.toTopOrRefresh();
|
||||
_dynamicController.animateToTop();
|
||||
}
|
||||
}
|
||||
_lastSelectTime = now;
|
||||
|
||||
Reference in New Issue
Block a user