add radio

This commit is contained in:
2026-10-28 19:17:35 +07:00
parent 0924d1d301
commit e3b65143a3
7 changed files with 372 additions and 6 deletions
+29
View File
@@ -7,6 +7,7 @@ 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::radio::{Radio, RadioGroup};
use gpui_native_core::switch::Switch;
use gpui_native_icons::{IconAssets, IconRole, icon};
use gpui_native_theme::{ActiveTheme as _, Theme};
@@ -16,6 +17,7 @@ struct Gallery {
button_clicks: usize,
checkbox_checked: bool,
switch_checked: bool,
plan: SharedString,
}
impl Render for Gallery {
@@ -268,6 +270,32 @@ impl Render for Gallery {
),
),
)
.child(
v_flex()
.gap_2()
.child(section_label(
"radio · native refs — NSButton (radio), WinUI RadioButton, Adwaita CheckButton (radio), Breeze",
colors,
))
.child({
let gallery = gallery.clone();
RadioGroup::new("gallery-radio-group")
.selected(Some(self.plan.clone()))
.on_change(move |plan, _, cx| {
gallery.update(cx, |gallery, cx| {
gallery.plan = plan;
cx.notify();
});
})
.child(Radio::new("radio-starter", SharedString::from("starter")).label("Starter"))
.child(Radio::new("radio-pro", SharedString::from("pro")).label("Pro"))
.child(
Radio::new("radio-team", SharedString::from("team"))
.label("Team")
.disabled(true),
)
}),
)
.child(
div()
.flex()
@@ -421,6 +449,7 @@ fn main() {
button_clicks: 0,
checkbox_checked: false,
switch_checked: true,
plan: SharedString::from("starter"),
})
},
) {