Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Enhance scroll physics for pull-to-reveal animation and update dependencies

AmanRajSinghMourya41ea52a749b7
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index 2c383b39c8..b0ca28eef9 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -1019,25 +1019,66 @@ class GalleryIndexUpdatedEvent {
class ExponentialBouncingScrollPhysics extends BouncingScrollPhysics {
const ExponentialBouncingScrollPhysics({
this.frictionExponent = 7.0,
+ this.topFrictionExponent = 2.0,
super.decelerationRate,
super.parent,
});
- /// The exponent used in the friction calculation.
+ /// The exponent used in the friction calculation for bottom overscroll.
///
/// A higher value will result in a more rapid increase in friction as the
/// user overscrolls. Defaults to 7.0.
final double frictionExponent;
+ /// The exponent used for top overscroll (pulling down).
+ /// Lower value means easier to pull. Defaults to 2.0.
+ final double topFrictionExponent;
+
@override
ExponentialBouncingScrollPhysics applyTo(ScrollPhysics? ancestor) {
return ExponentialBouncingScrollPhysics(
parent: buildParent(ancestor),
decelerationRate: decelerationRate,
frictionExponent: frictionExponent,
+ topFrictionExponent: topFrictionExponent,
);
}
+ @override
+ double applyPhysicsToUserOffset(ScrollMetrics position, double offset) {
+ assert(offset != 0.0);
+ assert(position.minScrollExtent <= position.maxScrollExtent);
+
+ if (!position.outOfRange) return offset;
+
+ final double overscrollPastStart =
+ math.max(position.minScrollExtent - position.pixels, 0.0);
+ final double overscrollPastEnd =
+ math.max(position.pixels - position.maxScrollExtent, 0.0);
+ final double overscrollPast =
+ math.max(overscrollPastStart, overscrollPastEnd);
+ final bool easing = (overscrollPastStart > 0.0 && offset < 0.0) ||
+ (overscrollPastEnd > 0.0 && offset > 0.0);
+
+ final double overscrollFraction =
+ overscrollPast / position.viewportDimension;
+
+ // Use lower friction for top overscroll (pulling down to reveal animation)
+ final bool isTopOverscroll = overscrollPastStart > 0.0;
+ final double exponent =
+ isTopOverscroll ? topFrictionExponent : frictionExponent;
+
+ final double baseFactor = switch (decelerationRate) {
+ ScrollDecelerationRate.fast => 0.26,
+ ScrollDecelerationRate.normal => 0.52,
+ };
+ final double friction = easing
+ ? baseFactor * math.exp(-overscrollFraction * exponent)
+ : baseFactor;
+
+ return offset * friction;
+ }
+
@override
double frictionFactor(double overscrollFraction) {
final double baseFactor = switch (decelerationRate) {
diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock
index edd9bcf6c1..0739aa5a6b 100644
--- a/mobile/apps/photos/pubspec.lock
+++ b/mobile/apps/photos/pubspec.lock
@@ -278,10 +278,10 @@ packages:
dependency: transitive
description:
name: camera_android_camerax
- sha256: "2c0746d55f513bed55f52e0b5d9bda18c1533bb16bb89ea93d8033f3815e6cd8"
+ sha256: "58b8fe843a3c83fd1273c00cb35f5a8ae507f6cc9b2029bcf7e2abba499e28d8"
url: "https://pub.dev"
source: hosted
- version: "0.6.23+1"
+ version: "0.6.19+1"
camera_avfoundation:
dependency: transitive
description:
@@ -3216,4 +3216,4 @@ packages:
version: "3.1.3"
sdks:
dart: ">=3.8.1 <4.0.0"
- flutter: ">=3.32.8"
+ flutter: ">=3.32.0"