Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quick actions #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading