-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmindful_app.dart
81 lines (72 loc) · 2.8 KB
/
mindful_app.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
*
* * Copyright (c) 2024 Mindful (https://github.com/akaMrNagar/Mindful)
* * Author : Pawan Nagar (https://github.com/akaMrNagar)
* *
* * This source code is licensed under the GPL-2.0 license license found in the
* * LICENSE file in the root directory of this source tree.
*
*/
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mindful/config/app_routes.dart';
import 'package:mindful/config/app_themes.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:mindful/core/services/routing_service.dart';
import 'package:mindful/providers/mindful_settings_provider.dart';
class MindfulApp extends ConsumerWidget {
const MindfulApp({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final themeMode =
ref.watch(mindfulSettingsProvider.select((v) => v.themeMode));
final accentColor =
ref.watch(mindfulSettingsProvider.select((v) => v.accentColor));
final localeCode =
ref.watch(mindfulSettingsProvider.select((v) => v.localeCode));
final useAmoledDark =
ref.watch(mindfulSettingsProvider.select((v) => v.useAmoledDark));
final useDynamicColors =
ref.watch(mindfulSettingsProvider.select((v) => v.useDynamicColors));
/// Apply transparent color to system ui background
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
systemNavigationBarContrastEnforced: true,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarColor: Colors.transparent,
),
);
return DynamicColorBuilder(
builder: (light, dark) => MaterialApp(
debugShowCheckedModeBanner: false,
themeAnimationCurve: Curves.ease,
darkTheme: AppTheme.darkTheme(
isAmoled: useAmoledDark,
seedColor: useDynamicColors
? dark?.primary
: AppTheme.materialColors[accentColor],
),
theme: AppTheme.lightTheme(
seedColor: useDynamicColors
? light?.primary
: AppTheme.materialColors[accentColor],
),
themeMode: ThemeMode.values[themeMode.index],
routes: AppRoutes.routes,
initialRoute: AppRoutes.splashScreen,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
locale: Locale(localeCode),
navigatorKey: RoutingService.navigatorKey,
),
);
}
}