From 0c41598c224d30bd921ac5c2a303cd83632e26f7 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:05:35 +0200 Subject: [PATCH] fix: Remove unnecessary Expended --- lib/App.dart | 276 +++++++++++++++++++++++++-------------------------- 1 file changed, 137 insertions(+), 139 deletions(-) diff --git a/lib/App.dart b/lib/App.dart index da50e91..9c127e4 100644 --- a/lib/App.dart +++ b/lib/App.dart @@ -62,115 +62,83 @@ class App extends StatelessWidget { child: DynamicColorBuilder( builder: (ColorScheme? lightColorScheme, ColorScheme? darkColorScheme) => - Expanded( - child: 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, - ); - } - + PlatformApp( + title: 'Locus', + material: (_, __) => MaterialAppData( + theme: (() { + if (lightColorScheme != null) { return LIGHT_THEME_MATERIAL.copyWith( colorScheme: settings.primaryColor == null - ? null + ? lightColorScheme : createColorScheme( - lightColorScheme ?? - ColorScheme.fromSwatch( - primarySwatch: - createMaterialColor(settings.primaryColor!), - ), + lightColorScheme, settings.primaryColor!, Brightness.light, ), - primaryColor: settings.primaryColor, + primaryColor: + settings.primaryColor ?? lightColorScheme.primary, ); - })(), - 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, + } + + 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, + ); + })(), + 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, ), ), - ); - } - - 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(), - ), - ); - } + ), + ); + } + if (darkColorScheme != null) { return DARK_THEME_MATERIAL.copyWith( colorScheme: settings.primaryColor == null - ? null + ? darkColorScheme : createColorScheme( - const ColorScheme.dark(), + darkColorScheme, settings.primaryColor!, Brightness.dark, ), - primaryColor: settings.primaryColor, - scaffoldBackgroundColor: settings.primaryColor == null - ? null - : HSLColor.fromColor(settings.primaryColor!) - .withLightness(0.08) - .toColor(), + primaryColor: + settings.primaryColor ?? darkColorScheme.primary, + scaffoldBackgroundColor: HSLColor.fromColor( + settings.primaryColor ?? darkColorScheme.background) + .withLightness(0.08) + .toColor(), dialogBackgroundColor: settings.primaryColor == null - ? null + ? darkColorScheme.background : HSLColor.fromColor(settings.primaryColor!) .withLightness(0.15) .toColor(), @@ -184,60 +152,90 @@ class App extends StatelessWidget { .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(); - } + } - return const LocationsOverviewScreen(); - })(); + 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 (isCupertino(context)) { - return MaterialWithModalsPageRoute( - builder: (_) => screen, - settings: routeSettings, - ); + if (!settings.userHasSeenWelcomeScreen) { + return const WelcomeScreen(); } - return NativePageRoute( + return const LocationsOverviewScreen(); + })(); + + if (isCupertino(context)) { + return MaterialWithModalsPageRoute( builder: (_) => screen, - context: context, + settings: routeSettings, ); - }, - ), + } + + return NativePageRoute( + builder: (_) => screen, + context: context, + ); + }, ), ), );