From 14b6c115b520c4286e1d1ed45fd56267dae88515 Mon Sep 17 00:00:00 2001 From: dom Date: Mon, 23 Feb 2026 11:44:39 +0800 Subject: [PATCH] opt refresh Signed-off-by: dom --- .../widgets/flutter/refresh_indicator.dart | 29 ++----------------- lib/pages/video/reply/view.dart | 6 +--- pubspec.lock | 2 +- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/lib/common/widgets/flutter/refresh_indicator.dart b/lib/common/widgets/flutter/refresh_indicator.dart index b260890f1..6c123df3e 100644 --- a/lib/common/widgets/flutter/refresh_indicator.dart +++ b/lib/common/widgets/flutter/refresh_indicator.dart @@ -7,6 +7,8 @@ import 'dart:io' show Platform; import 'package:PiliPlus/common/widgets/scroll_behavior.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; +import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart' + show RefreshScrollPhysics; import 'package:flutter/foundation.dart' show clampDouble; import 'package:flutter/material.dart' hide RefreshIndicator; @@ -593,30 +595,3 @@ class RefreshScrollBehavior extends CustomScrollBehavior { return scrollPhysics; } } - -typedef OnDrag = bool Function(double offset, double viewportDimension); - -class RefreshScrollPhysics extends ClampingScrollPhysics { - const RefreshScrollPhysics({ - super.parent, - required this.onDrag, - }); - - final OnDrag onDrag; - - @override - RefreshScrollPhysics applyTo(ScrollPhysics? ancestor) { - return RefreshScrollPhysics( - parent: buildParent(ancestor), - onDrag: onDrag, - ); - } - - @override - double applyPhysicsToUserOffset(ScrollMetrics position, double offset) { - if (offset < 0.0 && onDrag(offset, position.viewportDimension)) { - return 0.0; - } - return parent?.applyPhysicsToUserOffset(position, offset) ?? offset; - } -} diff --git a/lib/pages/video/reply/view.dart b/lib/pages/video/reply/view.dart index 67c775014..38841e6ee 100644 --- a/lib/pages/video/reply/view.dart +++ b/lib/pages/video/reply/view.dart @@ -81,11 +81,7 @@ class _VideoReplyPanelState extends State controller: widget.isNested ? null : _videoReplyController.scrollController, - physics: widget.isNested - ? const AlwaysScrollableScrollPhysics( - parent: ClampingScrollPhysics(), - ) - : const AlwaysScrollableScrollPhysics(), + physics: const AlwaysScrollableScrollPhysics(), key: const PageStorageKey(_VideoReplyPanelState), slivers: [ SliverPersistentHeader( diff --git a/pubspec.lock b/pubspec.lock index 69c4a4f32..80484a24d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -497,7 +497,7 @@ packages: description: path: "." ref: mod - resolved-ref: "4bb4e827628b3b7ccc88a4b98ef76a036a5a51ac" + resolved-ref: "00a86d9aeb05a797e6b24c9b6a71524b6e8ea2c8" url: "https://github.com/bggRGjQaUbCoE/extended_nested_scroll_view.git" source: git version: "6.2.1"