-
-
Notifications
You must be signed in to change notification settings - Fork 465
/
theme.dart
88 lines (77 loc) · 2.47 KB
/
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
import 'package:flutter/foundation.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'package:system_theme/system_theme.dart';
import 'package:fluent_ui/fluent_ui.dart';
enum NavigationIndicators { sticky, end }
class AppTheme extends ChangeNotifier {
AccentColor? _color;
AccentColor get color => _color ?? systemAccentColor;
set color(AccentColor color) {
_color = color;
notifyListeners();
}
ThemeMode _mode = ThemeMode.system;
ThemeMode get mode => _mode;
set mode(ThemeMode mode) {
_mode = mode;
notifyListeners();
}
PaneDisplayMode _displayMode = PaneDisplayMode.auto;
PaneDisplayMode get displayMode => _displayMode;
set displayMode(PaneDisplayMode displayMode) {
_displayMode = displayMode;
notifyListeners();
}
NavigationIndicators _indicator = NavigationIndicators.sticky;
NavigationIndicators get indicator => _indicator;
set indicator(NavigationIndicators indicator) {
_indicator = indicator;
notifyListeners();
}
WindowEffect _windowEffect = WindowEffect.disabled;
WindowEffect get windowEffect => _windowEffect;
set windowEffect(WindowEffect windowEffect) {
_windowEffect = windowEffect;
notifyListeners();
}
void setEffect(WindowEffect effect, BuildContext context) {
Window.setEffect(
effect: effect,
color: [
WindowEffect.solid,
WindowEffect.acrylic,
].contains(effect)
? FluentTheme.of(context).micaBackgroundColor.withOpacity(0.05)
: Colors.transparent,
dark: FluentTheme.of(context).brightness.isDark,
);
}
TextDirection _textDirection = TextDirection.ltr;
TextDirection get textDirection => _textDirection;
set textDirection(TextDirection direction) {
_textDirection = direction;
notifyListeners();
}
Locale? _locale;
Locale? get locale => _locale;
set locale(Locale? locale) {
_locale = locale;
notifyListeners();
}
}
AccentColor get systemAccentColor {
if ((defaultTargetPlatform == TargetPlatform.windows ||
defaultTargetPlatform == TargetPlatform.android) &&
!kIsWeb) {
return AccentColor.swatch({
'darkest': SystemTheme.accentColor.darkest,
'darker': SystemTheme.accentColor.darker,
'dark': SystemTheme.accentColor.dark,
'normal': SystemTheme.accentColor.accent,
'light': SystemTheme.accentColor.light,
'lighter': SystemTheme.accentColor.lighter,
'lightest': SystemTheme.accentColor.lightest,
});
}
return Colors.blue;
}