add slider

This commit is contained in:
2026-10-28 19:52:35 +07:00
parent 818266a25f
commit 5f441518eb
4 changed files with 480 additions and 0 deletions
+31
View File
@@ -9,6 +9,7 @@ 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::slider::Slider;
use gpui_native_core::switch::Switch;
use gpui_native_core::toggle::Toggle;
use gpui_native_icons::{IconAssets, IconRole, icon};
@@ -21,6 +22,7 @@ struct Gallery {
switch_checked: bool,
plan: SharedString,
toggle_pressed: bool,
volume: f32,
}
impl Render for Gallery {
@@ -362,6 +364,34 @@ impl Render for Gallery {
),
),
)
.child(
v_flex()
.gap_2()
.child(section_label(
"slider · native refs — NSSlider, WinUI Slider, Adwaita Scale, Breeze Slider",
colors,
))
.child({
let gallery = gallery.clone();
Slider::new("gallery-slider", self.volume)
.min(0.0)
.max(100.0)
.step(5.0)
.accessibility_label("Volume")
.on_change(move |volume, _, cx| {
gallery.update(cx, |gallery, cx| {
gallery.volume = volume;
cx.notify();
});
})
})
.child(
div()
.text_xs()
.text_color(colors.muted_foreground)
.child(format!("volume: {}", self.volume)),
),
)
.child(
div()
.flex()
@@ -517,6 +547,7 @@ fn main() {
switch_checked: true,
plan: SharedString::from("starter"),
toggle_pressed: false,
volume: 40.0,
})
},
) {