parent
64aa975c77
commit
8abaa82233
3 changed files with 11 additions and 9 deletions
|
|
@ -270,7 +270,12 @@ impl ListDelegate for CompanyListDelegate {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_item(&mut self, ix: IndexPath, _: &mut Window, _: &mut Context<ListState<Self>>) -> Option<Self::Item> {
|
fn render_item(
|
||||||
|
&mut self,
|
||||||
|
ix: IndexPath,
|
||||||
|
_: &mut Window,
|
||||||
|
_: &mut Context<ListState<Self>>,
|
||||||
|
) -> Option<Self::Item> {
|
||||||
let selected = Some(ix) == self.selected_index || Some(ix) == self.confirmed_index;
|
let selected = Some(ix) == self.selected_index || Some(ix) == self.confirmed_index;
|
||||||
if let Some(company) = self.matched_companies[ix.section].get(ix.row) {
|
if let Some(company) = self.matched_companies[ix.section].get(ix.row) {
|
||||||
return Some(CompanyListItem::new(ix, company.clone(), selected));
|
return Some(CompanyListItem::new(ix, company.clone(), selected));
|
||||||
|
|
|
||||||
|
|
@ -147,10 +147,6 @@ impl RowsCache {
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn measured_size(&self) -> MeasuredEntrySize {
|
|
||||||
self.measured_size
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn prepare_if_needed<F>(
|
pub(crate) fn prepare_if_needed<F>(
|
||||||
&mut self,
|
&mut self,
|
||||||
sections_count: usize,
|
sections_count: usize,
|
||||||
|
|
@ -207,7 +203,7 @@ impl RowsCache {
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::{list::cache::RowsCache, IndexPath};
|
use crate::{IndexPath, list::cache::RowsCache};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_prev_next() {
|
fn test_prev_next() {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ impl Default for ListOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The state for List.
|
/// The state for List.
|
||||||
|
///
|
||||||
|
/// List required all items has the same height.
|
||||||
pub struct ListState<D: ListDelegate> {
|
pub struct ListState<D: ListDelegate> {
|
||||||
pub(crate) focus_handle: FocusHandle,
|
pub(crate) focus_handle: FocusHandle,
|
||||||
pub(crate) query_input: Entity<InputState>,
|
pub(crate) query_input: Entity<InputState>,
|
||||||
|
|
@ -447,6 +449,7 @@ where
|
||||||
.id(id)
|
.id(id)
|
||||||
.w_full()
|
.w_full()
|
||||||
.relative()
|
.relative()
|
||||||
|
.overflow_hidden()
|
||||||
.children(self.delegate.render_item(ix, window, cx).map(|item| {
|
.children(self.delegate.render_item(ix, window, cx).map(|item| {
|
||||||
item.selected(selected)
|
item.selected(selected)
|
||||||
.secondary_selected(mouse_right_clicked)
|
.secondary_selected(mouse_right_clicked)
|
||||||
|
|
@ -483,13 +486,11 @@ where
|
||||||
let rows_cache = self.rows_cache.clone();
|
let rows_cache = self.rows_cache.clone();
|
||||||
let scrollbar_visible = self.options.scrollbar_visible;
|
let scrollbar_visible = self.options.scrollbar_visible;
|
||||||
let scroll_handle = self.scroll_handle.clone();
|
let scroll_handle = self.scroll_handle.clone();
|
||||||
let measured_size = rows_cache.measured_size();
|
|
||||||
|
|
||||||
v_flex()
|
v_flex()
|
||||||
.flex_grow()
|
.flex_grow()
|
||||||
.relative()
|
.relative()
|
||||||
.h_full()
|
.size_full()
|
||||||
.min_w(measured_size.item_size.width)
|
|
||||||
.when_some(self.options.max_height, |this, h| this.max_h(h))
|
.when_some(self.options.max_height, |this, h| this.max_h(h))
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.when(items_count == 0, |this| {
|
.when(items_count == 0, |this| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue