-
Notifications
You must be signed in to change notification settings - Fork 61
/
mirai_theme.dart
112 lines (108 loc) · 4.45 KB
/
mirai_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
106
107
108
109
110
111
112
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/mirai.dart';
import 'package:mirai/src/parsers/mirai_app_bar_theme/mirai_app_bar_theme.dart';
import 'package:mirai/src/parsers/mirai_bottom_sheet_theme/mirai_bottom_sheet_theme.dart';
import 'package:mirai/src/parsers/mirai_color_scheme/mirai_color_scheme.dart';
import 'package:mirai/src/parsers/mirai_icon_theme_data/mirai_icon_theme_data.dart';
import 'package:mirai/src/parsers/mirai_input_decoration_theme/mirai_input_decoration_theme.dart';
import 'package:mirai/src/parsers/mirai_material_color/mirai_material_color.dart';
import 'package:mirai/src/utils/color_utils.dart';
part 'mirai_theme.freezed.dart';
part 'mirai_theme.g.dart';
@freezed
class MiraiTheme with _$MiraiTheme {
const factory MiraiTheme({
bool? applyElevationOverlayColor,
MiraiInputDecorationTheme? inputDecorationTheme,
bool? useMaterial3,
Brightness? brightness,
String? canvasColor,
String? cardColor,
MiraiColorScheme? colorScheme,
String? colorSchemeSeed,
String? dialogBackgroundColor,
String? disabledColor,
String? dividerColor,
String? focusColor,
String? highlightColor,
String? hintColor,
String? hoverColor,
String? indicatorColor,
String? primaryColor,
String? primaryColorDark,
String? primaryColorLight,
MiraiMaterialColor? primarySwatch,
String? scaffoldBackgroundColor,
String? secondaryHeaderColor,
String? shadowColor,
String? splashColor,
String? unselectedWidgetColor,
MiraiAppBarTheme? appBarTheme,
MiraiButtonStyle? elevatedButtonTheme,
MiraiButtonStyle? outlinedButtonTheme,
MiraiButtonStyle? iconButtonTheme,
MiraiIconThemeData? iconTheme,
MiraiIconThemeData? primaryIconTheme,
MiraiDialogTheme? dialogTheme,
MiraiFloatingActionButtonThemeData? floatingActionButtonTheme,
MiraiButtonStyle? textButtonTheme,
MiraiBottomAppBarTheme? bottomAppBarTheme,
MiraiBottomNavBarThemeData? bottomNavigationBarTheme,
MiraiBottomSheetThemeData? bottomSheetTheme,
MiraiCardThemeData? cardTheme,
MiraiListTileThemeData? listTileTheme,
MiraiNavigationBarThemeData? navigationBarTheme,
MiraiTabBarThemeData? tabBarTheme,
}) = _MiraiTheme;
factory MiraiTheme.fromJson(Map<String, dynamic> json) =>
_$MiraiThemeFromJson(json);
}
extension MiraiThemeParser on MiraiTheme {
ThemeData? get parse {
return ThemeData(
applyElevationOverlayColor: applyElevationOverlayColor,
inputDecorationTheme: inputDecorationTheme.parse,
useMaterial3: useMaterial3,
brightness: brightness,
canvasColor: canvasColor?.toColor,
colorScheme: colorScheme?.parse,
colorSchemeSeed: colorSchemeSeed.toColor,
dialogBackgroundColor: dialogBackgroundColor.toColor,
disabledColor: disabledColor.toColor,
dividerColor: dividerColor.toColor,
focusColor: focusColor.toColor,
highlightColor: highlightColor.toColor,
hintColor: hintColor.toColor,
hoverColor: hoverColor.toColor,
indicatorColor: indicatorColor.toColor,
primaryColor: primaryColor.toColor,
primaryColorDark: primaryColorDark.toColor,
primaryColorLight: primaryColorLight.toColor,
scaffoldBackgroundColor: scaffoldBackgroundColor.toColor,
secondaryHeaderColor: secondaryHeaderColor.toColor,
shadowColor: shadowColor.toColor,
splashColor: splashColor.toColor,
unselectedWidgetColor: unselectedWidgetColor.toColor,
primarySwatch: primarySwatch?.parse,
appBarTheme: appBarTheme?.parse,
elevatedButtonTheme:
ElevatedButtonThemeData(style: elevatedButtonTheme?.parseElevated),
outlinedButtonTheme:
OutlinedButtonThemeData(style: outlinedButtonTheme?.parseOutlined),
iconButtonTheme: IconButtonThemeData(style: iconButtonTheme?.parseIcon),
iconTheme: iconTheme?.parse,
primaryIconTheme: primaryIconTheme?.parse,
dialogTheme: dialogTheme?.parse,
floatingActionButtonTheme: floatingActionButtonTheme?.parse,
textButtonTheme: TextButtonThemeData(style: textButtonTheme?.parseText),
bottomAppBarTheme: bottomAppBarTheme?.parse,
bottomNavigationBarTheme: bottomNavigationBarTheme?.parse,
bottomSheetTheme: bottomSheetTheme?.parse,
cardTheme: cardTheme?.parse,
listTileTheme: listTileTheme?.parse,
navigationBarTheme: navigationBarTheme?.parse,
tabBarTheme: tabBarTheme?.parse,
);
}
}