From d2a5145324156eb1b21da0365da626a91d85b5f1 Mon Sep 17 00:00:00 2001 From: Juan Gilsanz Polo Date: Tue, 11 Jun 2024 22:30:55 +0200 Subject: [PATCH] Added support for predictive back gesture --- android/app/src/main/AndroidManifest.xml | 3 +- lib/config/theme.dart | 40 +++++++++++++++++------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 03a410b..2eec292 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -4,7 +4,8 @@ + android:icon="@mipmap/ic_launcher" + android:enableOnBackInvokedCallback="true"> diff --git a/lib/config/theme.dart b/lib/config/theme.dart index 3f3beff..2aaa4ce 100644 --- a/lib/config/theme.dart +++ b/lib/config/theme.dart @@ -13,12 +13,15 @@ ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData( brightness: Brightness.light, listTileTheme: ListTileThemeData( tileColor: Colors.transparent, - textColor: dynamicColorScheme != null - ? dynamicColorScheme.onSurfaceVariant - : const Color.fromRGBO(117, 117, 117, 1), - iconColor: dynamicColorScheme != null - ? dynamicColorScheme.onSurfaceVariant - : const Color.fromRGBO(117, 117, 117, 1), + textColor: + dynamicColorScheme != null ? dynamicColorScheme.onSurfaceVariant : const Color.fromRGBO(117, 117, 117, 1), + iconColor: + dynamicColorScheme != null ? dynamicColorScheme.onSurfaceVariant : const Color.fromRGBO(117, 117, 117, 1), + ), + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), + }, ), ); @@ -35,12 +38,15 @@ ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData( brightness: Brightness.dark, listTileTheme: ListTileThemeData( tileColor: Colors.transparent, - textColor: dynamicColorScheme != null - ? dynamicColorScheme.onSurfaceVariant - : const Color.fromRGBO(187, 187, 187, 1), - iconColor: dynamicColorScheme != null - ? dynamicColorScheme.onSurfaceVariant - : const Color.fromRGBO(187, 187, 187, 1), + textColor: + dynamicColorScheme != null ? dynamicColorScheme.onSurfaceVariant : const Color.fromRGBO(187, 187, 187, 1), + iconColor: + dynamicColorScheme != null ? dynamicColorScheme.onSurfaceVariant : const Color.fromRGBO(187, 187, 187, 1), + ), + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), + }, ), ); @@ -58,6 +64,11 @@ ThemeData lightThemeOldVersions(MaterialColor primaryColor) => ThemeData( iconColor: Color.fromRGBO(117, 117, 117, 1), ), brightness: Brightness.light, + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), + }, + ), ); ThemeData darkThemeOldVersions(MaterialColor primaryColor) => ThemeData( @@ -75,4 +86,9 @@ ThemeData darkThemeOldVersions(MaterialColor primaryColor) => ThemeData( iconColor: Color.fromRGBO(187, 187, 187, 1), ), brightness: Brightness.dark, + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), + }, + ), );