add popover
This commit is contained in:
@@ -10,6 +10,7 @@ use gpui_native_core::checkbox::Checkbox;
|
||||
use gpui_native_core::common::{Sizable as _, h_flex, v_flex};
|
||||
use gpui_native_core::input::{Input, InputState};
|
||||
use gpui_native_core::link::Link;
|
||||
use gpui_native_core::popover::Popover;
|
||||
use gpui_native_core::progress::Progress;
|
||||
use gpui_native_core::radio::{Radio, RadioGroup};
|
||||
use gpui_native_core::slider::Slider;
|
||||
@@ -27,6 +28,7 @@ struct Gallery {
|
||||
toggle_pressed: bool,
|
||||
volume: f32,
|
||||
input_state: Entity<InputState>,
|
||||
popover_open: bool,
|
||||
}
|
||||
|
||||
impl Render for Gallery {
|
||||
@@ -275,6 +277,47 @@ impl Render for Gallery {
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"popover · native ref — NSPopover, WinUI Flyout, Adwaita Popover",
|
||||
colors,
|
||||
))
|
||||
.child({
|
||||
let gallery = gallery.clone();
|
||||
Popover::new("gallery-popover")
|
||||
.open(self.popover_open)
|
||||
.on_change(move |open, _, cx| {
|
||||
gallery.update(cx, |gallery, cx| {
|
||||
gallery.popover_open = open;
|
||||
cx.notify();
|
||||
});
|
||||
})
|
||||
.trigger(|_, _| {
|
||||
Button::new("gallery-popover-trigger")
|
||||
.label("Options")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.into_any_element()
|
||||
})
|
||||
.content(move |_, _| {
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.w(px(240.))
|
||||
.p_2()
|
||||
.child(section_label("appearance", colors))
|
||||
.child(
|
||||
Checkbox::new("gallery-popover-telemetry")
|
||||
.label("Enable telemetry"),
|
||||
)
|
||||
.child(
|
||||
Checkbox::new("gallery-popover-crash")
|
||||
.label("Send crash reports"),
|
||||
)
|
||||
.into_any_element()
|
||||
})
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
@@ -627,6 +670,7 @@ fn main() {
|
||||
toggle_pressed: false,
|
||||
volume: 40.0,
|
||||
input_state,
|
||||
popover_open: false,
|
||||
})
|
||||
},
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user