Skip to content

Commit

Permalink
fix: Move ManageQuickActions into correct tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Nov 11, 2023
1 parent b0487d1 commit f437d36
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 177 deletions.
343 changes: 178 additions & 165 deletions lib/App.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
);
},
),
),
);
}
Expand Down
Loading

0 comments on commit f437d36

Please sign in to comment.