use gpui::{AnyElement, App, Context, IntoElement, ParentElement as _, Styled as _, Task, Window};
use super::{ListState, loading::Loading};
use crate::{ActiveTheme as _, Icon, IconName, IndexPath, Selectable, Sizable, h_flex};
#[allow(unused)]
pub trait ListDelegate: Sized + 'static {
type Item: Selectable + IntoElement;
fn perform_search(
&mut self, _query: &str, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) -> Task<()> {
Task::ready(())
}
fn sections_count(&self, _cx: &App) -> usize {
1
}
fn items_count(&self, section: usize, cx: &App) -> usize;
fn render_item(
&mut self, ix: IndexPath, window: &mut Window, cx: &mut Context<ListState<Self>>,
) -> Option<Self::Item>;
fn render_section_header(
&mut self, _section: usize, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) -> Option<impl IntoElement> {
None::<AnyElement>
}
fn render_section_footer(
&mut self, _section: usize, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) -> Option<impl IntoElement> {
None::<AnyElement>
}
fn render_empty(
&mut self, _window: &mut Window, cx: &mut Context<ListState<Self>>,
) -> impl IntoElement {
h_flex()
.size_full()
.justify_center()
.text_color(cx.theme().muted_foreground)
.child(Icon::new(IconName::Search).small())
.into_any_element()
}
fn render_initial(
&mut self, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) -> Option<AnyElement> {
None
}
fn loading(&self, _cx: &App) -> bool {
false
}
fn render_loading(
&mut self, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) -> impl IntoElement {
Loading
}
fn set_selected_index(
&mut self, ix: Option<IndexPath>, window: &mut Window, cx: &mut Context<ListState<Self>>,
);
fn set_right_clicked_index(
&mut self, _ix: Option<IndexPath>, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) {
}
fn confirm(
&mut self, _secondary: bool, _window: &mut Window, _cx: &mut Context<ListState<Self>>,
) {
}
fn cancel(&mut self, _window: &mut Window, _cx: &mut Context<ListState<Self>>) {}
fn has_more(&self, _cx: &App) -> bool {
false
}
fn load_more_threshold(&self) -> usize {
20
}
fn load_more(&mut self, _window: &mut Window, _cx: &mut Context<ListState<Self>>) {}
}