forked from bdlukaa/fluent_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputs.dart
239 lines (229 loc) · 7.66 KB
/
inputs.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import 'package:fluent_ui/fluent_ui.dart';
class InputsPage extends StatefulWidget {
const InputsPage({Key? key}) : super(key: key);
@override
_InputsPageState createState() => _InputsPageState();
}
class _InputsPageState extends State<InputsPage> {
bool disabled = false;
bool value = false;
double sliderValue = 5;
double get max => 9;
final FlyoutController controller = FlyoutController();
final ScrollController scrollController = ScrollController();
@override
void dispose() {
controller.dispose();
scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ScaffoldPage(
header: PageHeader(
title: Text('Inputs showcase'),
commandBar: InfoLabel(
label: 'Disabled',
isHeader: false,
child: ToggleSwitch(
checked: disabled,
onChanged: (v) => setState(() => disabled = v),
),
),
),
content: SingleChildScrollView(
controller: scrollController,
padding: EdgeInsets.symmetric(
horizontal: PageHeader.horizontalPadding(context),
),
child: Wrap(spacing: 10, runSpacing: 10, children: [
Acrylic(
padding: EdgeInsets.all(8.0),
margin: EdgeInsets.only(bottom: 8.0),
child: InfoLabel(
label: 'Interactive Inputs',
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Checkbox(
checked: value,
onChanged: disabled
? null
: (v) => setState(() => value = v ?? false),
),
ToggleSwitch(
checked: value,
onChanged:
disabled ? null : (v) => setState(() => value = v),
),
RadioButton(
checked: value,
onChanged:
disabled ? null : (v) => setState(() => value = v),
),
ToggleButton(
child: Text('Toggle Button'),
checked: value,
onChanged: disabled
? null
: (value) => setState(() => this.value = value),
),
],
),
),
),
_buildButtons(),
_buildSliders(),
Acrylic(
padding: EdgeInsets.all(10.0),
child: Flyout(
content: Padding(
padding: EdgeInsets.only(left: 27),
child: FlyoutContent(
padding: EdgeInsets.zero,
child: ListView(shrinkWrap: true, children: [
TappableListTile(title: Text('New'), onTap: () {}),
TappableListTile(title: Text('Open'), onTap: () {}),
TappableListTile(title: Text('Save'), onTap: () {}),
TappableListTile(title: Text('Exit'), onTap: () {}),
]),
),
),
verticalOffset: 20,
contentWidth: 100,
controller: controller,
child: Button(
child: Text('File'),
onPressed: disabled ? null : () => controller.open = true,
),
),
),
]),
),
);
}
Widget _buildButtons() {
final splitButtonHeight = 50.0;
return Acrylic(
padding: EdgeInsets.all(8),
child: InfoLabel(
label: 'Buttons',
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Button(
child: Text('Show Dialog'),
onPressed: disabled
? null
: () {
showDialog(
context: context,
builder: (_) => ContentDialog(
title: Text('Delete file permanently?'),
content: Text(
'If you delete this file, you won\'t be able to recover it. Do you want to delete it?',
),
actions: [
Button(
child: Text('Delete'),
autofocus: true,
onPressed: () {
// Delete file here
},
),
Button(
child: Text('Cancel'),
onPressed: () => Navigator.pop(context),
),
],
),
);
},
),
Button.icon(
icon: Icon(Icons.add),
onPressed: disabled ? null : () => print('pressed icon button'),
),
SizedBox(
height: splitButtonHeight,
child: SplitButtonBar(buttons: [
Button(
builder: (context, states) {
return SizedBox(
height: splitButtonHeight,
child: Container(
color: states.isDisabled
? FluentTheme.of(context).accentColor.darker
: context.theme.accentColor,
height: 24,
width: 24,
),
);
},
onPressed: disabled ? null : () {},
),
Button(
child: SizedBox(
height: splitButtonHeight,
child: Icon(
Icons.keyboard_arrow_down,
color:
disabled ? FluentTheme.of(context).disabledColor : null,
),
),
onPressed: disabled ? null : () {},
style: ButtonThemeData(padding: EdgeInsets.all(6)),
),
]),
),
]),
),
);
}
Widget _buildSliders() {
return Acrylic(
padding: EdgeInsets.all(8),
child: InfoLabel(
label: 'Sliders',
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Row(mainAxisSize: MainAxisSize.min, children: [
Flexible(
fit: FlexFit.loose,
child: Column(children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 8),
width: 200,
child: Slider(
max: max,
label: '${sliderValue.toInt()}',
value: sliderValue,
onChanged: disabled
? null
: (v) => setState(() => sliderValue = v),
divisions: 10,
),
),
RatingBar(
amount: max.toInt(),
rating: sliderValue,
onChanged:
disabled ? null : (v) => setState(() => sliderValue = v),
),
]),
),
Container(
margin: EdgeInsets.all(8),
child: Slider(
vertical: true,
max: max,
label: '${sliderValue.toInt()}',
value: sliderValue,
onChanged:
disabled ? null : (v) => setState(() => sliderValue = v),
style: SliderThemeData(useThumbBall: false),
),
),
]),
]),
),
);
}
}