opt refresh

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-02-23 11:44:39 +08:00
parent ee188da6b0
commit 14b6c115b5
3 changed files with 4 additions and 33 deletions

View File

@@ -7,6 +7,8 @@ import 'dart:io' show Platform;
import 'package:PiliPlus/common/widgets/scroll_behavior.dart'; import 'package:PiliPlus/common/widgets/scroll_behavior.dart';
import 'package:PiliPlus/utils/storage_pref.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/foundation.dart' show clampDouble;
import 'package:flutter/material.dart' hide RefreshIndicator; import 'package:flutter/material.dart' hide RefreshIndicator;
@@ -593,30 +595,3 @@ class RefreshScrollBehavior extends CustomScrollBehavior {
return scrollPhysics; 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;
}
}

View File

@@ -81,11 +81,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
controller: widget.isNested controller: widget.isNested
? null ? null
: _videoReplyController.scrollController, : _videoReplyController.scrollController,
physics: widget.isNested physics: const AlwaysScrollableScrollPhysics(),
? const AlwaysScrollableScrollPhysics(
parent: ClampingScrollPhysics(),
)
: const AlwaysScrollableScrollPhysics(),
key: const PageStorageKey(_VideoReplyPanelState), key: const PageStorageKey(_VideoReplyPanelState),
slivers: <Widget>[ slivers: <Widget>[
SliverPersistentHeader( SliverPersistentHeader(

View File

@@ -497,7 +497,7 @@ packages:
description: description:
path: "." path: "."
ref: mod ref: mod
resolved-ref: "4bb4e827628b3b7ccc88a4b98ef76a036a5a51ac" resolved-ref: "00a86d9aeb05a797e6b24c9b6a71524b6e8ea2c8"
url: "https://github.com/bggRGjQaUbCoE/extended_nested_scroll_view.git" url: "https://github.com/bggRGjQaUbCoE/extended_nested_scroll_view.git"
source: git source: git
version: "6.2.1" version: "6.2.1"