add toggle and link
This commit is contained in:
@@ -13,3 +13,9 @@ pub mod switch;
|
||||
|
||||
#[cfg(feature = "radio")]
|
||||
pub mod radio;
|
||||
|
||||
#[cfg(feature = "toggle")]
|
||||
pub mod toggle;
|
||||
|
||||
#[cfg(feature = "link")]
|
||||
pub mod link;
|
||||
|
||||
@@ -7,8 +7,10 @@ use gpui::{
|
||||
use gpui_native_core::button::{Button, ButtonVariant};
|
||||
use gpui_native_core::checkbox::Checkbox;
|
||||
use gpui_native_core::common::{h_flex, v_flex};
|
||||
use gpui_native_core::link::Link;
|
||||
use gpui_native_core::radio::{Radio, RadioGroup};
|
||||
use gpui_native_core::switch::Switch;
|
||||
use gpui_native_core::toggle::Toggle;
|
||||
use gpui_native_icons::{IconAssets, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, Theme};
|
||||
use gpui_platform::application;
|
||||
@@ -18,6 +20,7 @@ struct Gallery {
|
||||
checkbox_checked: bool,
|
||||
switch_checked: bool,
|
||||
plan: SharedString,
|
||||
toggle_pressed: bool,
|
||||
}
|
||||
|
||||
impl Render for Gallery {
|
||||
@@ -296,6 +299,69 @@ impl Render for Gallery {
|
||||
)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"toggle · native refs — NSButton (toggle), WinUI ToggleButton, Adwaita ToggleButton, Breeze",
|
||||
colors,
|
||||
))
|
||||
.child(
|
||||
h_flex().gap_2().child({
|
||||
let gallery = gallery.clone();
|
||||
Toggle::new("gallery-toggle")
|
||||
.label("Bold")
|
||||
.pressed(self.toggle_pressed)
|
||||
.on_change(move |pressed, _, cx| {
|
||||
gallery.update(cx, |gallery, cx| {
|
||||
gallery.toggle_pressed = pressed;
|
||||
cx.notify();
|
||||
});
|
||||
})
|
||||
})
|
||||
.child(
|
||||
Toggle::new("gallery-toggle-disabled")
|
||||
.label("Disabled")
|
||||
.pressed(true)
|
||||
.disabled(true),
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"link · native refs — NSTextView links, WinUI HyperlinkButton, Adwaita LinkButton, Breeze",
|
||||
colors,
|
||||
))
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_4()
|
||||
.child(
|
||||
Link::new("gallery-link-github")
|
||||
.label("gpui on GitHub")
|
||||
.href("https://github.com/zed-industries/zed"),
|
||||
)
|
||||
.child({
|
||||
let gallery = gallery.clone();
|
||||
Link::new("gallery-link-override")
|
||||
.label("On-click override")
|
||||
.href("https://example.com/never-opened")
|
||||
.on_click(move |_, _, cx| {
|
||||
gallery.update(cx, |gallery, cx| {
|
||||
gallery.button_clicks += 1;
|
||||
cx.notify();
|
||||
});
|
||||
})
|
||||
})
|
||||
.child(
|
||||
Link::new("gallery-link-disabled")
|
||||
.label("Disabled")
|
||||
.href("https://example.com/disabled")
|
||||
.disabled(true),
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
@@ -450,6 +516,7 @@ fn main() {
|
||||
checkbox_checked: false,
|
||||
switch_checked: true,
|
||||
plan: SharedString::from("starter"),
|
||||
toggle_pressed: false,
|
||||
})
|
||||
},
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user