mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-23 20:10:12 +08:00
opt iOS ScrollPhysics
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
// ignore_for_file: prefer_initializing_formals
|
||||
|
||||
import 'dart:async' show Completer;
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/scroll_behavior.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart'
|
||||
show BouncingScrollPhysicsExt;
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:extended_nested_scroll_view/src/refresh.dart';
|
||||
import 'package:flutter/foundation.dart' show clampDouble;
|
||||
@@ -543,8 +545,19 @@ class RefreshIndicatorState extends State<RefreshIndicator>
|
||||
),
|
||||
],
|
||||
);
|
||||
if (!widget.isClampingScrollPhysics &&
|
||||
(Platform.isIOS || Platform.isMacOS)) {
|
||||
if (PlatformUtils.isDarwin) {
|
||||
if (widget.isClampingScrollPhysics) {
|
||||
return ScrollConfiguration(
|
||||
behavior: RefreshScrollBehavior(
|
||||
desktopDragDevices,
|
||||
scrollPhysics: RefreshScrollPhysicsIOS(
|
||||
parent: const RangeMaintainingScrollPhysics(),
|
||||
onDrag: _onDrag,
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
return ScrollConfiguration(
|
||||
@@ -640,3 +653,19 @@ class RefreshScrollPhysics extends ClampingScrollPhysics
|
||||
return RefreshScrollPhysics(parent: buildParent(ancestor), onDrag: onDrag);
|
||||
}
|
||||
}
|
||||
|
||||
class RefreshScrollPhysicsIOS extends BouncingScrollPhysicsExt
|
||||
with RefreshScrollPhysicsMixin {
|
||||
const RefreshScrollPhysicsIOS({super.parent, required this.onDrag});
|
||||
|
||||
@override
|
||||
final OnDrag onDrag;
|
||||
|
||||
@override
|
||||
RefreshScrollPhysicsIOS applyTo(ScrollPhysics? ancestor) {
|
||||
return RefreshScrollPhysicsIOS(
|
||||
parent: buildParent(ancestor),
|
||||
onDrag: onDrag,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user