StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | use pathfinder_color::ColorU; |
| 2 | use strato_ui::{elements::Rect, AppContext, Element, Entity, TypedActionView, View}; |
| 3 | |
| 4 | pub struct RootView {} |
| 5 | |
| 6 | // Implement the entity trait. |
| 7 | impl Entity for RootView { |
| 8 | type Event = (); |
| 9 | } |
| 10 | |
| 11 | // Implement the view trait so RootView could be considered as a view. |
| 12 | impl View for RootView { |
| 13 | fn ui_name() -> &'static str { |
| 14 | "RootView" |
| 15 | } |
| 16 | |
| 17 | // Let's render a simple black rect background. |
| 18 | fn render(&self, _: &AppContext) -> Box<dyn Element> { |
| 19 | Rect::new().with_background_color(ColorU::black()).finish() |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | impl TypedActionView for RootView { |
| 24 | type Action = (); |
| 25 | } |
| 26 |