StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | use strato_core::inspector::{inspector, InspectorConfig}; |
| 2 | use strato_core::types::Color; |
| 3 | use strato_macros::view; |
| 4 | use strato_platform::{ApplicationBuilder, WindowBuilder}; |
| 5 | use strato_widgets::prelude::*; |
| 6 | use strato_widgets::InspectorOverlay; |
| 7 | |
| 8 | #[tokio::main] |
| 9 | async fn main() -> anyhow::Result<()> { |
| 10 | tracing_subscriber::fmt::init(); |
| 11 | |
| 12 | inspector().configure(InspectorConfig { |
| 13 | enabled: true, |
| 14 | ..Default::default() |
| 15 | }); |
| 16 | |
| 17 | let builder = ApplicationBuilder::new() |
| 18 | .title("Macro DSL Showcase") |
| 19 | .window(WindowBuilder::new().with_size(800.0, 600.0)); |
| 20 | |
| 21 | // Using the view! macro to declaratively build the UI |
| 22 | let root = view! { |
| 23 | Container { |
| 24 | padding: 20.0, |
| 25 | background: Color::WHITE, |
| 26 | child: Column { |
| 27 | spacing: 15.0, |
| 28 | children: [ |
| 29 | Text { "Declarative UI with Macros!" }, |
| 30 | Container { |
| 31 | padding: 10.0, |
| 32 | background: Color::rgba(0.9, 0.9, 0.9, 1.0), |
| 33 | child: Text { "This entire structure is built using the view! macro." } |
| 34 | }, |
| 35 | Row { |
| 36 | spacing: 10.0, |
| 37 | children: [ |
| 38 | Button { "Cancel" }, |
| 39 | Button { "Submit" } |
| 40 | ] |
| 41 | } |
| 42 | ] |
| 43 | } |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | // Create legacy registry |
| 48 | let registry = strato_widgets::registry::create_default_registry(); |
| 49 | |
| 50 | // Build the widget tree using the registry |
| 51 | let root_widget = registry.build(root); |
| 52 | |
| 53 | builder.run(InspectorOverlay::new(root_widget)); |
| 54 | } |
| 55 |