audit input
This commit is contained in:
@@ -974,6 +974,7 @@ struct InputDemo {
|
||||
text: Entity<InputState>,
|
||||
password: Entity<InputState>,
|
||||
notes: Entity<InputState>,
|
||||
search: Entity<InputState>,
|
||||
_subscriptions: Vec<gpui::Subscription>,
|
||||
}
|
||||
|
||||
@@ -984,17 +985,20 @@ impl InputDemo {
|
||||
password.update(cx, |state, cx| state.set_password(true, cx));
|
||||
let notes = InputState::new(cx);
|
||||
notes.update(cx, |state, cx| state.set_multiline(true, cx));
|
||||
let search = InputState::new(cx);
|
||||
// The panel is a cached view in the dock: the value readouts re-render
|
||||
// only when the inputs it reads are notified.
|
||||
let subscriptions = vec![
|
||||
cx.observe(&text, |_, _, cx| cx.notify()),
|
||||
cx.observe(&password, |_, _, cx| cx.notify()),
|
||||
cx.observe(¬es, |_, _, cx| cx.notify()),
|
||||
cx.observe(&search, |_, _, cx| cx.notify()),
|
||||
];
|
||||
Self {
|
||||
text,
|
||||
password,
|
||||
notes,
|
||||
search,
|
||||
_subscriptions: subscriptions,
|
||||
}
|
||||
}
|
||||
@@ -1007,7 +1011,36 @@ impl Render for InputDemo {
|
||||
ScrollArea::new("input-demo").size_full().p_4().child(
|
||||
v_flex()
|
||||
.gap_3()
|
||||
.child(Input::new("input-demo-text", self.text.clone()).placeholder("Type here…"))
|
||||
.child(
|
||||
Input::new("input-demo-search", self.search.clone())
|
||||
.placeholder("Search")
|
||||
.prefix(
|
||||
Button::new("input-demo-search-prefix")
|
||||
.icon(IconRole::Search)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.small()
|
||||
.accessibility_label("Search"),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
Input::new("input-demo-text", self.text.clone())
|
||||
.placeholder("Type here…")
|
||||
.suffix(
|
||||
Button::new("input-demo-clear")
|
||||
.icon(IconRole::Close)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.small()
|
||||
.accessibility_label("Clear")
|
||||
.on_click({
|
||||
let text = self.text.clone();
|
||||
move |_, window, cx| {
|
||||
text.update(cx, |state, cx| {
|
||||
state.set_value("", window, cx)
|
||||
});
|
||||
}
|
||||
}),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
Input::new("input-demo-password", self.password.clone())
|
||||
.placeholder("Password"),
|
||||
|
||||
Reference in New Issue
Block a user