forked from bdlukaa/fluent_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.dart
173 lines (165 loc) · 5.57 KB
/
forms.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
// ignore_for_file: avoid_print
import 'package:fluent_ui/fluent_ui.dart';
class Forms extends StatefulWidget {
const Forms({Key? key}) : super(key: key);
@override
_FormsState createState() => _FormsState();
}
class _FormsState extends State<Forms> {
final autoSuggestBox = TextEditingController();
final _clearController = TextEditingController();
bool _showPassword = false;
final values = ['Blue', 'Green', 'Yellow', 'Red'];
String? comboBoxValue;
DateTime date = DateTime.now();
@override
Widget build(BuildContext context) {
return ScaffoldPage(
header: const PageHeader(title: Text('Forms showcase')),
content: ListView(
padding: EdgeInsets.only(
bottom: kPageDefaultVerticalPadding,
left: PageHeader.horizontalPadding(context),
right: PageHeader.horizontalPadding(context),
),
children: [
const TextBox(
header: 'Email',
placeholder: 'Type your email here :)',
),
const SizedBox(height: 20),
Row(children: [
const Expanded(
child: TextBox(
readOnly: true,
placeholder: 'Read only text box',
),
),
const SizedBox(width: 10),
const Expanded(
child: TextBox(
enabled: false,
placeholder: 'Disabled text box',
),
),
const SizedBox(width: 10),
Expanded(
child: AutoSuggestBox<String>(
controller: autoSuggestBox,
items: values,
onSelected: (text) {
print(text);
},
textBoxBuilder: (context, controller, focusNode, key) {
return TextBox(
key: key,
controller: controller,
focusNode: focusNode,
suffixMode: OverlayVisibilityMode.editing,
suffix: IconButton(
icon: const Icon(FluentIcons.close),
onPressed: () {
controller.clear();
focusNode.unfocus();
},
),
placeholder: 'Type a color',
clipBehavior:
focusNode.hasFocus ? Clip.none : Clip.antiAlias,
);
},
),
),
]),
const SizedBox(height: 20),
TextBox(
maxLines: null,
controller: _clearController,
suffixMode: OverlayVisibilityMode.always,
minHeight: 100,
suffix: IconButton(
icon: const Icon(FluentIcons.close),
onPressed: () {
_clearController.clear();
},
),
placeholder: 'Text box with clear button',
),
const SizedBox(height: 20),
TextBox(
header: 'Password',
placeholder: 'Type your placeholder here',
obscureText: !_showPassword,
maxLines: 1,
suffixMode: OverlayVisibilityMode.always,
suffix: IconButton(
icon: Icon(
!_showPassword ? FluentIcons.lock : FluentIcons.unlock,
),
onPressed: () => setState(() => _showPassword = !_showPassword),
),
outsideSuffix: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Button(
child: const Text('Done'),
onPressed: () {},
),
),
),
const SizedBox(height: 20),
Mica(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Wrap(runSpacing: 8, children: [
SizedBox(
width: 200,
child: InfoLabel(
label: 'Colors',
child: Combobox<String>(
placeholder: const Text('Choose a color'),
isExpanded: true,
items: values
.map((e) => ComboboxItem<String>(
value: e,
child: Text(e),
))
.toList(),
value: comboBoxValue,
onChanged: (value) {
print(value);
if (value != null) {
setState(() => comboBoxValue = value);
}
},
),
),
),
const SizedBox(width: 12),
SizedBox(
width: 295,
child: DatePicker(
// popupHeight: kOneLineTileHeight * 6,
header: 'Date of birth',
selected: date,
onChanged: (v) => setState(() => date = v),
),
),
const SizedBox(width: 12),
SizedBox(
width: 240,
child: TimePicker(
// popupHeight: kOneLineTileHeight * 5,
header: 'Arrival time',
selected: date,
onChanged: (v) => setState(() => date = v),
),
),
]),
),
),
const SizedBox(height: 20),
],
),
);
}
}