add select component built on menu
This commit is contained in:
@@ -20,6 +20,7 @@ use gpui_native_core::popover::Popover;
|
||||
use gpui_native_core::progress::Progress;
|
||||
use gpui_native_core::radio::{Radio, RadioGroup};
|
||||
use gpui_native_core::scroll_area::ScrollArea;
|
||||
use gpui_native_core::select::{Select, SelectOption};
|
||||
use gpui_native_core::slider::Slider;
|
||||
use gpui_native_core::switch::Switch;
|
||||
use gpui_native_core::toast::{Toast, ToastAction, Toasts, ToastsView};
|
||||
@@ -43,6 +44,7 @@ struct Gallery {
|
||||
input_state: Entity<InputState>,
|
||||
popover_open: bool,
|
||||
menu_open: bool,
|
||||
strategy: Option<Strategy>,
|
||||
dialog_open: bool,
|
||||
alert_open: bool,
|
||||
update_alert_dismissed: bool,
|
||||
@@ -56,6 +58,13 @@ struct Gallery {
|
||||
sidebar_selected: Option<usize>,
|
||||
}
|
||||
|
||||
/// The select section's demo value.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Strategy {
|
||||
Curated,
|
||||
Uncensored,
|
||||
}
|
||||
|
||||
/// A demo model for the tree section: the app owns the real tree and its
|
||||
/// expansion set, and flattens the visible nodes for the component.
|
||||
#[derive(Clone)]
|
||||
@@ -410,6 +419,49 @@ impl Render for Gallery {
|
||||
})
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"select · native refs — NSPopUpButton, WinUI ComboBox, Adwaita Dropdown",
|
||||
colors,
|
||||
))
|
||||
.child({
|
||||
let gallery = gallery.clone();
|
||||
div().w(gpui::px(280.)).flex().flex_col().gap_3().child(
|
||||
Select::new("gallery-strategy")
|
||||
.options(vec![
|
||||
SelectOption::new(Strategy::Curated, "Curated")
|
||||
.icon(IconRole::Check),
|
||||
SelectOption::new(Strategy::Uncensored, "Uncensored")
|
||||
.icon(IconRole::Warning),
|
||||
])
|
||||
.selected(self.strategy)
|
||||
.placeholder("Fetching strategy")
|
||||
.on_change(move |next, _, cx| {
|
||||
gallery.update(cx, |gallery, cx| {
|
||||
gallery.strategy = next;
|
||||
cx.notify();
|
||||
});
|
||||
}),
|
||||
)
|
||||
})
|
||||
.child({
|
||||
div().w(gpui::px(280.)).child(
|
||||
Select::new("gallery-size")
|
||||
.options(vec![
|
||||
("small", "Small"),
|
||||
("medium", "Medium"),
|
||||
("large", "Large"),
|
||||
])
|
||||
.selected("medium")
|
||||
.placeholder("Control size")
|
||||
.small(),
|
||||
)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
@@ -1277,6 +1329,7 @@ fn main() {
|
||||
input_state,
|
||||
popover_open: false,
|
||||
menu_open: false,
|
||||
strategy: Some(Strategy::Curated),
|
||||
dialog_open: false,
|
||||
alert_open: false,
|
||||
update_alert_dismissed: false,
|
||||
|
||||
Reference in New Issue
Block a user