forked from bdlukaa/fluent_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.dart
204 lines (196 loc) · 6.49 KB
/
settings.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import 'package:flutter/foundation.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart' as flutter_acrylic;
import 'package:provider/provider.dart';
import '../theme.dart';
const List<String> accentColorNames = [
'System',
'Yellow',
'Orange',
'Red',
'Magenta',
'Purple',
'Blue',
'Teal',
'Green',
];
class Settings extends StatelessWidget {
const Settings({Key? key, this.controller}) : super(key: key);
final ScrollController? controller;
@override
Widget build(BuildContext context) {
final appTheme = context.watch<AppTheme>();
final tooltipThemeData = TooltipThemeData(decoration: () {
const radius = BorderRadius.zero;
final shadow = [
BoxShadow(
color: Colors.black.withOpacity(0.2),
offset: const Offset(1, 1),
blurRadius: 10.0,
),
];
final border = Border.all(color: Colors.grey[100], width: 0.5);
if (FluentTheme.of(context).brightness == Brightness.light) {
return BoxDecoration(
color: Colors.white,
borderRadius: radius,
border: border,
boxShadow: shadow,
);
} else {
return BoxDecoration(
color: Colors.grey,
borderRadius: radius,
border: border,
boxShadow: shadow,
);
}
}());
const spacer = SizedBox(height: 10.0);
const biggerSpacer = SizedBox(height: 40.0);
return ScaffoldPage(
header: const PageHeader(title: Text('Settings')),
content: ListView(
padding: EdgeInsets.only(
bottom: kPageDefaultVerticalPadding,
left: PageHeader.horizontalPadding(context),
right: PageHeader.horizontalPadding(context),
),
controller: controller,
children: [
Text('Theme mode',
style: FluentTheme.of(context).typography.subtitle),
spacer,
...List.generate(ThemeMode.values.length, (index) {
final mode = ThemeMode.values[index];
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: RadioButton(
checked: appTheme.mode == mode,
onChanged: (value) {
if (value) {
appTheme.mode = mode;
}
},
content: Text('$mode'.replaceAll('ThemeMode.', '')),
),
);
}),
biggerSpacer,
Text(
'Navigation Pane Display Mode',
style: FluentTheme.of(context).typography.subtitle,
),
spacer,
...List.generate(PaneDisplayMode.values.length, (index) {
final mode = PaneDisplayMode.values[index];
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: RadioButton(
checked: appTheme.displayMode == mode,
onChanged: (value) {
if (value) appTheme.displayMode = mode;
},
content: Text(
mode.toString().replaceAll('PaneDisplayMode.', ''),
),
),
);
}),
biggerSpacer,
Text('Navigation Indicator',
style: FluentTheme.of(context).typography.subtitle),
spacer,
...List.generate(NavigationIndicators.values.length, (index) {
final mode = NavigationIndicators.values[index];
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: RadioButton(
checked: appTheme.indicator == mode,
onChanged: (value) {
if (value) appTheme.indicator = mode;
},
content: Text(
mode.toString().replaceAll('NavigationIndicators.', ''),
),
),
);
}),
biggerSpacer,
Text('Accent Color',
style: FluentTheme.of(context).typography.subtitle),
spacer,
Wrap(children: [
Tooltip(
style: tooltipThemeData,
child: _buildColorBlock(appTheme, systemAccentColor),
message: accentColorNames[0],
),
...List.generate(Colors.accentColors.length, (index) {
final color = Colors.accentColors[index];
return Tooltip(
style: tooltipThemeData,
message: accentColorNames[index + 1],
child: _buildColorBlock(appTheme, color),
);
}),
]),
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) ...[
biggerSpacer,
Text('Window Transparency',
style: FluentTheme.of(context).typography.subtitle),
spacer,
...List.generate(flutter_acrylic.AcrylicEffect.values.length,
(index) {
final mode = flutter_acrylic.AcrylicEffect.values[index];
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: RadioButton(
checked: appTheme.acrylicEffect == mode,
onChanged: (value) {
if (value) {
appTheme.acrylicEffect = mode;
flutter_acrylic.Acrylic.setEffect(
effect: mode,
gradientColor: FluentTheme.of(context)
.acrylicBackgroundColor
.withOpacity(0.2),
);
}
},
content: Text(
mode.toString().replaceAll('AcrylicEffect.', ''),
),
),
);
}),
],
],
),
);
}
Widget _buildColorBlock(AppTheme appTheme, AccentColor color) {
return Padding(
padding: const EdgeInsets.all(2.0),
child: Button(
onPressed: () {
appTheme.color = color;
},
style: ButtonStyle(padding: ButtonState.all(EdgeInsets.zero)),
child: Container(
height: 40,
width: 40,
color: color,
alignment: Alignment.center,
child: appTheme.color == color
? Icon(
FluentIcons.check_mark,
color: color.basedOnLuminance(),
size: 22.0,
)
: null,
),
),
);
}
}