pub fn textfield(placeholder: &str, value: &str) -> ViewHandleExpand description
Create a TextField showing a fixed string, which the user cannot edit.
The string becomes a Binding.constant and SwiftUI treats that as
read-only: keystrokes have nowhere to be written, so the field ignores them.
textfield_bound is the one that can be typed into.
Examples found in repository?
examples/ios_app.rs (line 251)
211fn controls() -> views::ViewHandle {
212 views::vstack_spacing(
213 &[
214 // Two toggles, both starting `false`: one bound to Rust-owned
215 // state, one a constant. If they ever disagree on screen, the
216 // binding's getter is at fault rather than the control.
217 views::toggle_bound("Bound to Rust state", switch_state()),
218 views::toggle("Constant false", false),
219 views::hstack_spacing(
220 &[
221 label_text(&format!("{:.2}", slider_state().get()), 14.0, None, 0.9),
222 views::slider_bound(slider_state(), 0.0, 1.0),
223 ],
224 10.0,
225 ),
226 views::stepper_bound(
227 &format!("Stepper: {:.0}", stepper_state().get()),
228 stepper_state(),
229 0.0,
230 10.0,
231 1.0,
232 ),
233 // Reads the stepper's Rust value. A `ProgressView` takes a plain
234 // number rather than a binding, so it can only ever show what it
235 // was built with — which is fine now that every write rebuilds the
236 // body from current state.
237 views::progress(stepper_state().get(), 10.0),
238 views::hstack_spacing(
239 &[
240 views::button_style(
241 &views::button("Bordered", on_tap),
242 views::ButtonStyle::Bordered,
243 ),
244 views::button_style(
245 &views::button("Glass", on_tap),
246 views::ButtonStyle::Glass,
247 ),
248 ],
249 12.0,
250 ),
251 views::textfield("A text field", ""),
252 ],
253 12.0,
254 )
255}