mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: top or refresh debounce
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -2,6 +2,7 @@ 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,10 +13,13 @@ abstract mixin class ScrollOrRefreshMixin {
|
||||
|
||||
Future<void> onRefresh();
|
||||
|
||||
FutureOr<void> toTopOrRefresh() {
|
||||
void toTopOrRefresh() {
|
||||
if (scrollController.hasClients) {
|
||||
if (scrollController.position.pixels == 0) {
|
||||
return onRefresh();
|
||||
EasyThrottle.throttle('topOrRefresh', const Duration(milliseconds: 500),
|
||||
() {
|
||||
onRefresh();
|
||||
});
|
||||
} else {
|
||||
animateToTop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user