StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | //! Control gallery demonstrating integrated interaction states and accessibility semantics. |
| 2 | |
| 3 | use strato_sdk::prelude::*; |
| 4 | use strato_sdk::strato_widgets::{Checkbox, Slider}; |
| 5 | use strato_sdk::InitBuilder; |
| 6 | |
| 7 | fn main() { |
| 8 | InitBuilder::new() |
| 9 | .init_all() |
| 10 | .expect("Failed to initialize StratoSDK"); |
| 11 | |
| 12 | ApplicationBuilder::new() |
| 13 | .title("Control gallery") |
| 14 | .window(WindowBuilder::new().with_size(640.0, 420.0)) |
| 15 | .run(build_ui()); |
| 16 | } |
| 17 | |
| 18 | fn stateful_buttons() -> impl Widget { |
| 19 | let mut focus_preview = Button::new("Focused").style(ButtonStyle::outline()); |
| 20 | focus_preview.set_state(WidgetState::Focused); |
| 21 | |
| 22 | let mut pressed_preview = Button::new("Pressed").style(ButtonStyle::ghost()); |
| 23 | pressed_preview.set_state(WidgetState::Pressed); |
| 24 | |
| 25 | Column::new().spacing(12.0).children(vec![ |
| 26 | Box::new( |
| 27 | Button::new("Primary") |
| 28 | .primary() |
| 29 | .accessibility_hint("Activates the primary action"), |
| 30 | ), |
| 31 | Box::new( |
| 32 | Button::new("Disabled") |
| 33 | .enabled(false) |
| 34 | .accessibility_hint("Disabled to show the dimmed state"), |
| 35 | ), |
| 36 | Box::new(focus_preview), |
| 37 | Box::new(pressed_preview), |
| 38 | ]) |
| 39 | } |
| 40 | |
| 41 | fn toggles() -> impl Widget { |
| 42 | let checked = Checkbox::new().label("Notifications").checked(true); |
| 43 | let disabled = Checkbox::new().label("Location access").enabled(false); |
| 44 | |
| 45 | Column::new() |
| 46 | .spacing(8.0) |
| 47 | .children(vec![Box::new(checked), Box::new(disabled)]) |
| 48 | } |
| 49 | |
| 50 | fn sliders() -> impl Widget { |
| 51 | let mut disabled_slider = Slider::new(0.0, 100.0).enabled(false); |
| 52 | disabled_slider.set_value(45.0); |
| 53 | |
| 54 | Column::new().spacing(10.0).children(vec![ |
| 55 | Box::new(Slider::new(0.0, 100.0).size(260.0, 32.0)), |
| 56 | Box::new(disabled_slider), |
| 57 | ]) |
| 58 | } |
| 59 | |
| 60 | fn build_ui() -> impl Widget { |
| 61 | Container::new() |
| 62 | .padding(24.0) |
| 63 | .child(Row::new().spacing(32.0).children(vec![ |
| 64 | Box::new(stateful_buttons()), |
| 65 | Box::new(toggles()), |
| 66 | Box::new(sliders()), |
| 67 | ])) |
| 68 | } |
| 69 |