From 583ccdea5202c7f35f852dd913f07b7e497827b0 Mon Sep 17 00:00:00 2001 From: nyne Date: Sun, 19 Oct 2025 15:22:12 +0800 Subject: [PATCH] Support predict back --- lib/components/page_route.dart | 41 +++++++++++++++++++++------------- pubspec.lock | 26 ++++++++++----------- pubspec.yaml | 4 ++-- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lib/components/page_route.dart b/lib/components/page_route.dart index 24337b8..325070d 100644 --- a/lib/components/page_route.dart +++ b/lib/components/page_route.dart @@ -2,6 +2,7 @@ import 'dart:math'; import 'dart:ui'; import 'package:flutter/gestures.dart'; import 'package:fluent_ui/fluent_ui.dart'; +import 'package:flutter/material.dart' show PredictiveBackPageTransitionsBuilder; import 'package:pixes/foundation/app.dart'; const double _kBackGestureWidth = 20.0; @@ -141,21 +142,31 @@ mixin _AppRouteTransitionMixin on PageRoute { : child, ); } else { - child = DrillInPageTransition( - animation: CurvedAnimation( - parent: animation, - curve: FluentTheme - .of(context) - .animationCurve, - ), - child: enableIOSGesture && App.isIOS - ? IOSBackGestureDetector( - gestureWidth: _kBackGestureWidth, - enabledCallback: () => _isPopGestureEnabled(this), - onStartPopGesture: () => _startPopGesture(this), - child: child) - : child, - ); + if (App.isAndroid) { + child = const PredictiveBackPageTransitionsBuilder().buildTransitions( + this, + context, + animation, + secondaryAnimation, + child, + ); + } else { + child = DrillInPageTransition( + animation: CurvedAnimation( + parent: animation, + curve: FluentTheme + .of(context) + .animationCurve, + ), + child: enableIOSGesture && App.isIOS + ? IOSBackGestureDetector( + gestureWidth: _kBackGestureWidth, + enabledCallback: () => _isPopGestureEnabled(this), + onStartPopGesture: () => _startPopGesture(this), + child: child) + : child, + ); + } } return child; diff --git a/pubspec.lock b/pubspec.lock index 0b7dcdc..0933d69 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -237,10 +237,10 @@ packages: dependency: "direct main" description: name: fluent_ui - sha256: "8645eabacb46bfc9632fadc6e106756cdc6f2a4efb5a4fed4410bd3131306fe8" + sha256: "64223237a1d873b426d578d4d8b2703b8f7d9731608a5beb7b9745194568d484" url: "https://pub.dev" source: hosted - version: "4.12.0" + version: "4.13.0" flutter: dependency: "direct main" description: flutter @@ -361,26 +361,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" lints: dependency: transitive description: @@ -671,10 +671,10 @@ packages: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.6" typed_data: dependency: transitive description: @@ -759,10 +759,10 @@ packages: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: @@ -853,4 +853,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.8.0 <4.0.0" - flutter: ">=3.32.5" + flutter: ">=3.35.6" diff --git a/pubspec.yaml b/pubspec.yaml index e550993..01175c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,7 @@ version: 1.2.0+120 environment: sdk: '>=3.3.4 <4.0.0' - flutter: 3.32.5 + flutter: 3.35.6 # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -36,7 +36,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. window_manager: ^0.4.3 - fluent_ui: ^4.12.0 + fluent_ui: ^4.13.0 dynamic_color: ^1.7.0 dio: ^5.8.0 crypto: ^3.0.6