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();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -141,11 +142,14 @@ class _MainAppState extends State<MainApp>
|
||||
|
||||
int now = DateTime.now().millisecondsSinceEpoch;
|
||||
if (now - _lastSelectTime < 500) {
|
||||
if (currentPage is HomePage) {
|
||||
_homeController.onRefresh();
|
||||
} else if (currentPage is DynamicsPage) {
|
||||
_dynamicController.onRefresh();
|
||||
}
|
||||
EasyThrottle.throttle('topOrRefresh', const Duration(milliseconds: 500),
|
||||
() {
|
||||
if (currentPage is HomePage) {
|
||||
_homeController.onRefresh();
|
||||
} else if (currentPage is DynamicsPage) {
|
||||
_dynamicController.onRefresh();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (currentPage is HomePage) {
|
||||
_homeController.toTopOrRefresh();
|
||||
|
||||
@@ -284,6 +284,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
),
|
||||
),
|
||||
title: TextField(
|
||||
autofocus: true,
|
||||
readOnly: _attr != null && Utils.isDefault(_attr!),
|
||||
controller: _titleController,
|
||||
style: TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user