-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_theme.dart
105 lines (94 loc) · 3.74 KB
/
app_theme.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import 'package:flutter/material.dart';
import 'service_locator.dart';
import 'model/services/preferences_service.dart';
class AppTheme {
ThemeData light = ThemeData(
colorScheme: const ColorScheme(
brightness: Brightness.light,
primary: Color(0xFF056676),
onPrimary: Colors.white,
secondary: Color(0xffADF1E6),
onSecondary: Color(0xFF056676),
error: Color(0xffFF7283),
onError: Colors.white,
background: Colors.white,
onBackground: Colors.black,
surface: Color(0xffF5F5F5),
onSurface: Color(0xffB4B4B4),
),
textTheme: const TextTheme(
labelLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
labelMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
labelSmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
bodyLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w400),
bodyMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
bodySmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
headlineSmall: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
headlineMedium: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
headlineLarge: TextStyle(fontSize: 32, fontWeight: FontWeight.w700),
displaySmall: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
displayMedium: TextStyle(fontSize: 30, fontWeight: FontWeight.w800),
),
splashColor: Colors.white24,
useMaterial3: true
);
ThemeData dark = ThemeData(
colorScheme: const ColorScheme(
brightness: Brightness.dark,
primary: Color.fromARGB(255, 7, 121, 139),
onPrimary: Colors.white,
secondary: Color.fromARGB(255, 132, 186, 177),
onSecondary: Color(0xFF056676),
error: Color(0xffFF7283),
onError: Colors.white,
background: Colors.black,
onBackground: Colors.white,
surface: Color.fromARGB(255, 31, 31, 31),
onSurface: Color.fromARGB(255, 109, 109, 109)
),
textTheme: const TextTheme(
labelLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
labelMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
labelSmall: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
bodyLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w400),
bodyMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
bodySmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
headlineSmall: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
headlineMedium: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
headlineLarge: TextStyle(fontSize: 32, fontWeight: FontWeight.w700),
displaySmall: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
displayMedium: TextStyle(fontSize: 35, fontWeight: FontWeight.w700),
),
useMaterial3: true
);
}
class GlobalAppThemeConfig extends ChangeNotifier {
ThemeMode themeMode = ThemeMode.system;
String get themeModeString {
return {
ThemeMode.system: 'system',
ThemeMode.light: 'light',
ThemeMode.dark: 'dark'
}[themeMode] ?? 'system';
}
final PreferencesService _preferencesService = sl();
GlobalAppThemeConfig() {
final themeModeString = _preferencesService.getItem('themeMode');
if (themeModeString != null) {
themeMode = {
'system': ThemeMode.system,
'light': ThemeMode.light,
'dark': ThemeMode.dark
}[themeModeString] ?? ThemeMode.system;
}
}
void setThemeMode(String themeMode) {
this.themeMode = {
'system': ThemeMode.system,
'light': ThemeMode.light,
'dark': ThemeMode.dark
}[themeMode] ?? ThemeMode.system;
_preferencesService.saveItem('themeMode', themeMode);
notifyListeners();
}
}