diff --git a/examples/slider/src/main.rs b/examples/slider/src/main.rs index e9820aed43..f71dac01fa 100644 --- a/examples/slider/src/main.rs +++ b/examples/slider/src/main.rs @@ -11,10 +11,10 @@ pub enum Message { } pub struct Slider { - slider_value: u8, - slider_default: u8, - slider_step: u8, - slider_step_fine: u8, + value: u8, + default: u8, + step: u8, + shift_step: u8, } impl Sandbox for Slider { @@ -22,10 +22,10 @@ impl Sandbox for Slider { fn new() -> Slider { Slider { - slider_value: 50, - slider_default: 50, - slider_step: 5, - slider_step_fine: 1, + value: 50, + default: 50, + step: 5, + shift_step: 1, } } @@ -36,34 +36,29 @@ impl Sandbox for Slider { fn update(&mut self, message: Message) { match message { Message::SliderChanged(value) => { - self.slider_value = value; + self.value = value; } } } fn view(&self) -> Element { - let value = self.slider_value; - let default = self.slider_default; - let step = self.slider_step; - let step_fine = self.slider_step_fine; - let h_slider = container( - slider(0..=100, value, Message::SliderChanged) - .default(default) - .step(step) - .step_fine(step_fine), + slider(0..=100, self.value, Message::SliderChanged) + .default(self.default) + .step(self.step) + .shift_step(self.shift_step), ) .width(250); let v_slider = container( - vertical_slider(0..=100, value, Message::SliderChanged) - .default(default) - .step(step) - .step_fine(step_fine), + vertical_slider(0..=100, self.value, Message::SliderChanged) + .default(self.default) + .step(self.step) + .shift_step(self.shift_step), ) .height(200); - let text = text(format!("{value}")); + let text = text(self.value); container( column![