add list
This commit is contained in:
@@ -23,6 +23,7 @@ use gpui_native_core::switch::Switch;
|
||||
use gpui_native_core::toast::{Toast, ToastSeverity, Toasts, ToastsView};
|
||||
use gpui_native_core::toggle::Toggle;
|
||||
use gpui_native_core::tooltip::Tooltip;
|
||||
use gpui_native_data::list::{List, ListItem};
|
||||
use gpui_native_icons::{IconAssets, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, Theme};
|
||||
use gpui_platform::application;
|
||||
@@ -41,6 +42,7 @@ struct Gallery {
|
||||
alert_open: bool,
|
||||
toasts: Entity<Toasts>,
|
||||
scroll: gpui::ScrollHandle,
|
||||
list_selected: Option<usize>,
|
||||
}
|
||||
|
||||
impl Render for Gallery {
|
||||
@@ -339,6 +341,42 @@ impl Render for Gallery {
|
||||
})
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"list · native refs — NSTableView (list), WinUI ListView, Adwaita ListBox, Breeze",
|
||||
colors,
|
||||
))
|
||||
.child({
|
||||
let gallery = gallery.clone();
|
||||
List::new("gallery-list")
|
||||
.selected(self.list_selected)
|
||||
.on_change(move |selected, _, cx| {
|
||||
gallery.update(cx, |gallery, cx| {
|
||||
gallery.list_selected = selected;
|
||||
cx.notify();
|
||||
});
|
||||
})
|
||||
.items(|_, _| {
|
||||
vec![
|
||||
ListItem::new("Documents").icon(IconRole::Folder),
|
||||
ListItem::new("Pictures")
|
||||
.icon(IconRole::Folder)
|
||||
.detail("24 items"),
|
||||
ListItem::new("Music").icon(IconRole::Folder),
|
||||
ListItem::new("Archive").disabled(true),
|
||||
ListItem::new("Trash").detail("emptied weekly"),
|
||||
]
|
||||
})
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(colors.muted_foreground)
|
||||
.child(format!("selected: {:?}", self.list_selected)),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
@@ -957,6 +995,7 @@ fn main() {
|
||||
alert_open: false,
|
||||
toasts,
|
||||
scroll: gpui::ScrollHandle::new(),
|
||||
list_selected: None,
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user