From f437d36dde28feb2853a779201ba573c271545ab Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 11 Nov 2023 14:45:25 +0100 Subject: [PATCH] fix: Move ManageQuickActions into correct tree --- lib/App.dart | 343 +++++++++++++++++--------------- lib/screens/ShortcutScreen.dart | 22 +- 2 files changed, 188 insertions(+), 177 deletions(-) diff --git a/lib/App.dart b/lib/App.dart index 9c127e4..e04a98d 100644 --- a/lib/App.dart +++ b/lib/App.dart @@ -26,16 +26,14 @@ import 'app_wrappers/UpdateLocaleToSettings.dart'; import 'app_wrappers/UpdateLocationHistory.dart'; import 'constants/themes.dart'; -ColorScheme createColorScheme( - final ColorScheme baseScheme, - final Color primaryColor, - final Brightness brightness, -) { +ColorScheme createColorScheme(final ColorScheme baseScheme, + final Color primaryColor, + final Brightness brightness,) { switch (brightness) { case Brightness.dark: return baseScheme.copyWith( background: - HSLColor.fromColor(primaryColor).withLightness(0.3).toColor(), + HSLColor.fromColor(primaryColor).withLightness(0.3).toColor(), primary: primaryColor, brightness: brightness, surface: HSLColor.fromColor(primaryColor).withLightness(0.15).toColor(), @@ -62,181 +60,196 @@ class App extends StatelessWidget { child: DynamicColorBuilder( builder: (ColorScheme? lightColorScheme, ColorScheme? darkColorScheme) => - PlatformApp( - title: 'Locus', - material: (_, __) => MaterialAppData( - theme: (() { - if (lightColorScheme != null) { - return LIGHT_THEME_MATERIAL.copyWith( - colorScheme: settings.primaryColor == null - ? lightColorScheme - : createColorScheme( - lightColorScheme, + PlatformApp( + title: 'Locus', + material: (_, __) => + MaterialAppData( + theme: (() { + if (lightColorScheme != null) { + return LIGHT_THEME_MATERIAL.copyWith( + colorScheme: settings.primaryColor == null + ? lightColorScheme + : createColorScheme( + lightColorScheme, + settings.primaryColor!, + Brightness.light, + ), + primaryColor: + settings.primaryColor ?? lightColorScheme.primary, + ); + } + + return LIGHT_THEME_MATERIAL.copyWith( + colorScheme: settings.primaryColor == null + ? null + : createColorScheme( + lightColorScheme ?? + ColorScheme.fromSwatch( + primarySwatch: + createMaterialColor(settings.primaryColor!), + ), settings.primaryColor!, Brightness.light, ), - primaryColor: - settings.primaryColor ?? lightColorScheme.primary, - ); - } - - return LIGHT_THEME_MATERIAL.copyWith( - colorScheme: settings.primaryColor == null - ? null - : createColorScheme( - lightColorScheme ?? - ColorScheme.fromSwatch( - primarySwatch: - createMaterialColor(settings.primaryColor!), + primaryColor: settings.primaryColor, + ); + })(), + darkTheme: (() { + if (settings.getAndroidTheme() == AndroidTheme.miui) { + return DARK_THEME_MATERIAL_MIUI.copyWith( + colorScheme: settings.primaryColor == null + ? null + : createColorScheme( + const ColorScheme.dark(), + settings.primaryColor!, + Brightness.dark, + ), + primaryColor: settings.primaryColor, + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: + settings.primaryColor ?? MIUI_PRIMARY_COLOR, + foregroundColor: Colors.white, + splashFactory: NoSplash.splashFactory, + textStyle: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w700, + ), ), - settings.primaryColor!, - Brightness.light, - ), - primaryColor: settings.primaryColor, - ); - })(), - darkTheme: (() { - if (settings.getAndroidTheme() == AndroidTheme.miui) { - return DARK_THEME_MATERIAL_MIUI.copyWith( - colorScheme: settings.primaryColor == null - ? null - : createColorScheme( + ), + ); + } + + if (darkColorScheme != null) { + return DARK_THEME_MATERIAL.copyWith( + colorScheme: settings.primaryColor == null + ? darkColorScheme + : createColorScheme( + darkColorScheme, + settings.primaryColor!, + Brightness.dark, + ), + primaryColor: + settings.primaryColor ?? darkColorScheme.primary, + scaffoldBackgroundColor: HSLColor.fromColor( + settings.primaryColor ?? darkColorScheme + .background) + .withLightness(0.08) + .toColor(), + dialogBackgroundColor: settings.primaryColor == null + ? darkColorScheme.background + : HSLColor.fromColor(settings.primaryColor!) + .withLightness(0.15) + .toColor(), + inputDecorationTheme: + DARK_THEME_MATERIAL.inputDecorationTheme.copyWith( + fillColor: settings.primaryColor == null + ? null + : HSLColor.fromColor(settings.primaryColor!) + .withLightness(0.3) + .withSaturation(.5) + .toColor(), + ), + ); + } + + return DARK_THEME_MATERIAL.copyWith( + colorScheme: settings.primaryColor == null + ? null + : createColorScheme( const ColorScheme.dark(), settings.primaryColor!, Brightness.dark, ), - primaryColor: settings.primaryColor, - elevatedButtonTheme: ElevatedButtonThemeData( - style: ElevatedButton.styleFrom( - backgroundColor: - settings.primaryColor ?? MIUI_PRIMARY_COLOR, - foregroundColor: Colors.white, - splashFactory: NoSplash.splashFactory, - textStyle: const TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.w700, - ), + primaryColor: settings.primaryColor, + scaffoldBackgroundColor: settings.primaryColor == null + ? null + : HSLColor.fromColor(settings.primaryColor!) + .withLightness(0.08) + .toColor(), + dialogBackgroundColor: settings.primaryColor == null + ? null + : HSLColor.fromColor(settings.primaryColor!) + .withLightness(0.15) + .toColor(), + inputDecorationTheme: + DARK_THEME_MATERIAL.inputDecorationTheme.copyWith( + fillColor: settings.primaryColor == null + ? null + : HSLColor.fromColor(settings.primaryColor!) + .withLightness(0.3) + .withSaturation(.5) + .toColor(), + ), + ); + })(), + themeMode: ThemeMode.system, + ), + cupertino: (_, __) => + CupertinoAppData( + theme: settings.primaryColor == null + ? LIGHT_THEME_CUPERTINO + : LIGHT_THEME_CUPERTINO.copyWith( + primaryColor: settings.primaryColor, ), ), - ); - } - - if (darkColorScheme != null) { - return DARK_THEME_MATERIAL.copyWith( - colorScheme: settings.primaryColor == null - ? darkColorScheme - : createColorScheme( - darkColorScheme, - settings.primaryColor!, - Brightness.dark, - ), - primaryColor: - settings.primaryColor ?? darkColorScheme.primary, - scaffoldBackgroundColor: HSLColor.fromColor( - settings.primaryColor ?? darkColorScheme.background) - .withLightness(0.08) - .toColor(), - dialogBackgroundColor: settings.primaryColor == null - ? darkColorScheme.background - : HSLColor.fromColor(settings.primaryColor!) - .withLightness(0.15) - .toColor(), - inputDecorationTheme: - DARK_THEME_MATERIAL.inputDecorationTheme.copyWith( - fillColor: settings.primaryColor == null - ? null - : HSLColor.fromColor(settings.primaryColor!) - .withLightness(0.3) - .withSaturation(.5) - .toColor(), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + builder: (context, child) => + Stack( + children: [ + const UpdateLocationHistory(), + const UniLinksHandler(), + const UpdateLastLocationToSettings(), + const RegisterBackgroundListeners(), + const UpdateLocaleToSettings(), + const HandleNotifications(), + const CheckViewAlarmsLive(), + const InitCurrentLocationFromSettings(), + const ShowUpdateDialog(), + const PublishTaskPositionsOnUpdate(), + if (child != null) child, + ], ), - ); - } + onGenerateRoute: (routeSettings) { + final screen = (() { + if (settings.getRequireBiometricAuthenticationOnStart()) { + return const BiometricsRequiredStartupScreen(); + } - return DARK_THEME_MATERIAL.copyWith( - colorScheme: settings.primaryColor == null - ? null - : createColorScheme( - const ColorScheme.dark(), - settings.primaryColor!, - Brightness.dark, - ), - primaryColor: settings.primaryColor, - scaffoldBackgroundColor: settings.primaryColor == null - ? null - : HSLColor.fromColor(settings.primaryColor!) - .withLightness(0.08) - .toColor(), - dialogBackgroundColor: settings.primaryColor == null - ? null - : HSLColor.fromColor(settings.primaryColor!) - .withLightness(0.15) - .toColor(), - inputDecorationTheme: - DARK_THEME_MATERIAL.inputDecorationTheme.copyWith( - fillColor: settings.primaryColor == null - ? null - : HSLColor.fromColor(settings.primaryColor!) - .withLightness(0.3) - .withSaturation(.5) - .toColor(), - ), - ); - })(), - themeMode: ThemeMode.system, - ), - cupertino: (_, __) => CupertinoAppData( - theme: settings.primaryColor == null - ? LIGHT_THEME_CUPERTINO - : LIGHT_THEME_CUPERTINO.copyWith( - primaryColor: settings.primaryColor, - ), - ), - localizationsDelegates: AppLocalizations.localizationsDelegates, - supportedLocales: AppLocalizations.supportedLocales, - builder: (context, child) => Stack( - children: [ - const UpdateLocationHistory(), - const UniLinksHandler(), - const UpdateLastLocationToSettings(), - const RegisterBackgroundListeners(), - const UpdateLocaleToSettings(), - const HandleNotifications(), - const CheckViewAlarmsLive(), - const ManageQuickActions(), - const InitCurrentLocationFromSettings(), - const ShowUpdateDialog(), - const PublishTaskPositionsOnUpdate(), - if (child != null) child, - ], - ), - onGenerateRoute: (routeSettings) { - final screen = (() { - if (settings.getRequireBiometricAuthenticationOnStart()) { - return const BiometricsRequiredStartupScreen(); - } + if (!settings.userHasSeenWelcomeScreen) { + return const WelcomeScreen(); + } - if (!settings.userHasSeenWelcomeScreen) { - return const WelcomeScreen(); - } + return const Stack( + children: [ + ManageQuickActions(), + LocationsOverviewScreen(), + ], + ); + })(); - return const LocationsOverviewScreen(); - })(); + final screens = Stack( + children: [ + const ManageQuickActions(), + screen, + ] + ); - if (isCupertino(context)) { - return MaterialWithModalsPageRoute( - builder: (_) => screen, - settings: routeSettings, - ); - } + if (isCupertino(context)) { + return MaterialWithModalsPageRoute( + builder: (_) => screens, + settings: routeSettings, + ); + } - return NativePageRoute( - builder: (_) => screen, - context: context, - ); - }, - ), + return NativePageRoute( + builder: (_) => screens, + context: context, + ); + }, + ), ), ); } diff --git a/lib/screens/ShortcutScreen.dart b/lib/screens/ShortcutScreen.dart index 5bf8fe3..c9ceb8c 100644 --- a/lib/screens/ShortcutScreen.dart +++ b/lib/screens/ShortcutScreen.dart @@ -102,9 +102,10 @@ class _ShortcutScreenState extends State { ); await Future.wait( tasks.map( - (task) => task.publisher.publishLocation( - locationPoint.copyWithDifferentId(), - ), + (task) => + task.publisher.publishLocation( + locationPoint.copyWithDifferentId(), + ), ), ); @@ -116,10 +117,11 @@ class _ShortcutScreenState extends State { accuracy: locationPoint.accuracy, tasks: List.from( tasks.map( - (task) => UpdatedTaskData( - id: task.id, - name: task.name, - ), + (task) => + UpdatedTaskData( + id: task.id, + name: task.name, + ), ), ), ), @@ -141,11 +143,7 @@ class _ShortcutScreenState extends State { return; } - if (isPlatformApple()) { - Navigator.of(context).pop(); - } else { - SystemNavigator.pop(); - } + Navigator.of(context).pop(); } catch (_) { if (!mounted) { return;