Skip to content

armgit / ente

Public Imported from GitHub
0

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

Stick animation to top

AmanRajSinghMouryaccb4f1f81f82
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
index 9d0ee1451a..35d49a0b20 100644
--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart
+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
@@ -879,16 +879,25 @@ class _HomeWidgetState extends State<HomeWidget> {
},
child: NotificationListener<ScrollNotification>(
onNotification: (notification) {
+ const double maxPullOffset = 200.0;
+
if (notification is ScrollUpdateNotification) {
- final double overscroll = notification.metrics.pixels;
- if (overscroll < 0) {
- _christmasPullOffsetNotifier.value = -overscroll;
+ final double pixels = notification.metrics.pixels;
+ if (pixels < 0) {
+ if (pixels < -maxPullOffset) {
+ final scrollPosition =
+ Scrollable.of(notification.context!).position;
+ scrollPosition.correctBy(-maxPullOffset - pixels);
+ }
+
+ final double clampedOffset =
+ (-pixels).clamp(0.0, maxPullOffset);
+ _christmasPullOffsetNotifier.value = clampedOffset;
if (_christmasPullReleasedNotifier.value) {
_christmasPullReleasedNotifier.value = false;
}
} else if (_christmasPullOffsetNotifier.value != 0) {
_christmasPullOffsetNotifier.value = 0;
- // Don't reset released here - let fade animation complete
}
} else if (notification is ScrollEndNotification) {
if (_christmasPullOffsetNotifier.value > 0) {
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index b0ca28eef9..e39bf67fd0 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -1,6 +1,5 @@
import 'dart:async';
import "dart:io";
-import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -1011,80 +1010,11 @@ class GalleryIndexUpdatedEvent {
GalleryIndexUpdatedEvent(this.tag, this.index);
}
-/// Scroll physics similar to [BouncingScrollPhysics] but with exponentially
-/// increasing friction when scrolling out of bounds.
-///
-/// This creates a stronger resistance to overscrolling the further you go
-/// past the scroll boundary.
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 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;
+ const ExponentialBouncingScrollPhysics({super.parent});
@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) {
- ScrollDecelerationRate.fast => 0.26,
- ScrollDecelerationRate.normal => 0.52,
- };
- return baseFactor * math.exp(-overscrollFraction * frictionExponent);
+ return ExponentialBouncingScrollPhysics(parent: buildParent(ancestor));
}
}
diff --git a/mobile/packages/legacy/devtools_options.yaml b/mobile/packages/legacy/devtools_options.yaml
new file mode 100644
index 0000000000..fa0b357c4f
--- /dev/null
+++ b/mobile/packages/legacy/devtools_options.yaml
@@ -0,0 +1,3 @@
+description: This file stores settings for Dart & Flutter DevTools.
+documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
+extensions:
diff --git a/mobile/packages/sharing/devtools_options.yaml b/mobile/packages/sharing/devtools_options.yaml
new file mode 100644
index 0000000000..fa0b357c4f
--- /dev/null
+++ b/mobile/packages/sharing/devtools_options.yaml
@@ -0,0 +1,3 @@
+description: This file stores settings for Dart & Flutter DevTools.
+documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
+extensions: