Tidy up
This commit is contained in:
parent
ff15ddf3e0
commit
77d92ff65a
6 changed files with 134 additions and 62 deletions
|
@ -59,6 +59,7 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
let ix = cmp::min(index + 1, count - 1);
|
||||
self.delegate.set_selected_index(ix, cx);
|
||||
self.scroll_handle.scroll_to_item(ix);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,6 +70,7 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
let ix = index.saturating_sub(1);
|
||||
self.delegate.set_selected_index(ix, cx);
|
||||
self.scroll_handle.scroll_to_item(ix);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,6 +79,7 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
if count > 0 {
|
||||
self.delegate.set_selected_index(0, cx);
|
||||
self.scroll_handle.scroll_to_item(0);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,6 +88,7 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
if count > 0 {
|
||||
self.delegate.set_selected_index(count - 1, cx);
|
||||
self.scroll_handle.scroll_to_item(count - 1);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,18 +167,23 @@ impl<D: PickerDelegate> Render for Picker<D> {
|
|||
.bg(cx.theme().colors().element_background),
|
||||
)
|
||||
.child(
|
||||
v_stack().py_0p5().px_1().grow().max_h_96().child(
|
||||
uniform_list("candidates", self.delegate.match_count(), {
|
||||
move |this: &mut Self, visible_range, cx| {
|
||||
let selected_ix = this.delegate.selected_index();
|
||||
visible_range
|
||||
.map(|ix| this.delegate.render_match(ix, ix == selected_ix, cx))
|
||||
.collect()
|
||||
}
|
||||
})
|
||||
.track_scroll(self.scroll_handle.clone())
|
||||
.size_full(),
|
||||
),
|
||||
v_stack()
|
||||
.py_0p5()
|
||||
.px_1()
|
||||
.grow()
|
||||
.child(
|
||||
uniform_list("candidates", self.delegate.match_count(), {
|
||||
move |this: &mut Self, visible_range, cx| {
|
||||
let selected_ix = this.delegate.selected_index();
|
||||
visible_range
|
||||
.map(|ix| this.delegate.render_match(ix, ix == selected_ix, cx))
|
||||
.collect()
|
||||
}
|
||||
})
|
||||
.track_scroll(self.scroll_handle.clone()),
|
||||
)
|
||||
.max_h_72()
|
||||
.overflow_hidden(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue