-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
app_theme_type_extensions.dart
81 lines (77 loc) · 2.83 KB
/
app_theme_type_extensions.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
import 'package:flutter/material.dart';
import 'package:shiori/domain/enums/enums.dart';
extension AppThemeTypeExtensions on AppAccentColorType {
Color getAccentColor() {
switch (this) {
case AppAccentColorType.blue:
return Colors.blue;
case AppAccentColorType.green:
return Colors.green;
case AppAccentColorType.pink:
return Colors.pink;
case AppAccentColorType.brown:
return Colors.brown;
case AppAccentColorType.red:
return Colors.red;
case AppAccentColorType.cyan:
return Colors.cyan;
case AppAccentColorType.indigo:
return Colors.indigo;
case AppAccentColorType.purple:
return Colors.purple;
case AppAccentColorType.deepPurple:
return Colors.deepPurple;
case AppAccentColorType.grey:
return Colors.grey;
case AppAccentColorType.orange:
return Colors.orange;
case AppAccentColorType.yellow:
return Colors.yellow;
case AppAccentColorType.blueGrey:
return Colors.blueGrey;
case AppAccentColorType.teal:
return Colors.teal;
case AppAccentColorType.amber:
return Colors.amber;
default:
throw Exception('The provided accent color = $this is not valid ');
}
}
ThemeData getThemeData(AppThemeType theme, bool useDarkAmoledTheme) {
final color = getAccentColor();
switch (theme) {
case AppThemeType.dark:
final colorScheme = ColorScheme.dark(primary: color, secondary: color, primaryVariant: color, secondaryVariant: color);
final dark = ThemeData.dark().copyWith(
primaryColor: color,
primaryColorLight: color.withOpacity(0.5),
primaryColorDark: color,
useMaterial3: true,
colorScheme: colorScheme,
);
if (!useDarkAmoledTheme) {
return dark;
}
const almostBlackColor = Color.fromARGB(255, 20, 20, 20);
return dark.copyWith(
scaffoldBackgroundColor: Colors.black,
popupMenuTheme: const PopupMenuThemeData(color: almostBlackColor),
bottomSheetTheme: const BottomSheetThemeData(backgroundColor: almostBlackColor),
bottomNavigationBarTheme: const BottomNavigationBarThemeData(backgroundColor: almostBlackColor),
cardColor: almostBlackColor,
dialogBackgroundColor: almostBlackColor,
colorScheme: colorScheme.copyWith(surface: almostBlackColor),
);
case AppThemeType.light:
return ThemeData.light().copyWith(
primaryColor: color,
primaryColorLight: color.withOpacity(0.8),
primaryColorDark: color,
useMaterial3: true,
colorScheme: ColorScheme.light(primary: color, secondary: color),
);
default:
throw Exception('The provided theme = $theme is not valid ');
}
}
}