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
use crate::{
elements::{Element, TextFieldElement},
foundation::{colorspace::Color, Id, Key, ValueChanged, WidgetProperties},
gestures::DragStartBehavior,
painting::TextStyle,
services::{MouseCursor, TextInputType},
ui::{
BoxHeightStyle, BoxWidthStyle, Brightness, Radius, TextAlign, TextDirection, VoidCallback,
},
widgets::{FocusNode, Widget, TextEditingController},
};
use super::InputDecoration;
pub struct TextField {
pub key: Key,
pub controller: TextEditingController,
pub focus_node: FocusNode,
pub decoration: InputDecoration,
pub keyboard_type: TextInputType,
pub style: TextStyle,
pub text_align: TextAlign,
pub text_direction: TextDirection,
pub read_only: bool,
pub show_cursor: bool,
pub autofocus: bool,
pub obscuring_character: String,
pub obscure_text: bool,
pub autocorrect: bool,
pub enable_suggestions: bool,
pub max_lines: i32,
pub min_lines: i32,
pub expands: bool,
pub max_length: i32,
pub max_length_enforced: bool,
pub on_changed: Option<ValueChanged<String>>,
pub on_editing_complete: Option<VoidCallback>,
pub on_submitted: Option<ValueChanged<String>>,
pub enabled: bool,
pub cursor_width: f32,
pub cursor_height: f32,
pub cursor_radius: Radius,
pub cursor_color: Color,
pub selection_height_style: BoxHeightStyle,
pub selection_width_style: BoxWidthStyle,
pub keyboard_appearance: Brightness,
pub drag_start_behavior: DragStartBehavior,
pub enable_interactive_selection: bool,
pub mouse_cursor: MouseCursor,
pub autofill_hints: Vec<String>,
pub restoration_id: String,
pub enable_ime_personalized_learning: bool,
}
impl Default for TextField {
fn default() -> Self {
Self {
key: Default::default(),
controller: Default::default(),
focus_node: Default::default(),
decoration: Default::default(),
keyboard_type: Default::default(),
style: Default::default(),
text_align: Default::default(),
text_direction: Default::default(),
read_only: Default::default(),
show_cursor: Default::default(),
autofocus: Default::default(),
obscuring_character: Default::default(),
obscure_text: Default::default(),
autocorrect: Default::default(),
enable_suggestions: Default::default(),
max_lines: Default::default(),
min_lines: Default::default(),
expands: Default::default(),
max_length: Default::default(),
max_length_enforced: Default::default(),
on_changed: Default::default(),
on_editing_complete: Default::default(),
on_submitted: Default::default(),
enabled: Default::default(),
cursor_width: Default::default(),
cursor_height: Default::default(),
cursor_radius: Default::default(),
cursor_color: Default::default(),
selection_height_style: Default::default(),
selection_width_style: Default::default(),
keyboard_appearance: Default::default(),
drag_start_behavior: Default::default(),
enable_interactive_selection: Default::default(),
mouse_cursor: Default::default(),
autofill_hints: Default::default(),
restoration_id: Default::default(),
enable_ime_personalized_learning: Default::default(),
}
}
}
impl Widget for TextField {
fn create_element(&self) -> Box<dyn Element> {
box TextFieldElement::new(self)
}
}
impl WidgetProperties for TextField {
fn key(&self) -> &Key {
&self.key
}
fn x(&self) -> f32 {
0.0
}
fn y(&self) -> f32 {
0.0
}
fn w(&self) -> f32 {
0.0
}
fn h(&self) -> f32 {
0.0
}
fn w_min(&self) -> f32 {
0.0
}
fn h_min(&self) -> f32 {
0.0
}
fn w_max(&self) -> f32 {
0.0
}
fn h_max(&self) -> f32 {
0.0
}
fn parent(&self) -> Option<Id> {
None
}
fn depth(&self) -> f32 {
0.0
}
fn visible(&self) -> bool {
true
}
fn mouse_input(&self) -> bool {
true
}
fn key_input(&self) -> bool {
true
}
fn renderable(&self) -> bool {
true
}
fn internal_visible(&self) -> bool {
true
}
}