Skip to content

Commit

Permalink
fix: Remove unnecessary Expended
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Oct 15, 2023
1 parent 83595f4 commit 0c41598
Showing 1 changed file with 137 additions and 139 deletions.
276 changes: 137 additions & 139 deletions lib/App.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
);
},
),
),
);
Expand Down

0 comments on commit 0c41598

Please sign in to comment.