Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/examples/example-black-background-box/root_view.rs
1use pathfinder_color::ColorU;
2use strato_ui::{elements::Rect, AppContext, Element, Entity, TypedActionView, View};
3 
4pub struct RootView {}
5 
6// Implement the entity trait.
7impl Entity for RootView {
8 type Event = ();
9}
10 
11// Implement the view trait so RootView could be considered as a view.
12impl 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 
23impl TypedActionView for RootView {
24 type Action = ();
25}
26