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/blur/main.rs
1use anyhow::{anyhow, Result};
2use std::borrow::Cow;
3pub mod root_view;
4 
5extern crate strato_ui;
6use rust_embed::RustEmbed;
7use strato_ui::{platform, AssetProvider};
8 
9#[derive(Clone, Copy, RustEmbed)]
10#[folder = "examples/assets"]
11pub struct Assets;
12 
13// The static assets we need to load in app.
14pub static ASSETS: Assets = Assets;
15 
16// Implement the AssetProvider trait here (required by App::new).
17impl AssetProvider for Assets {
18 fn get(&self, path: &str) -> Result<Cow<'_, [u8]>> {
19 <Assets as RustEmbed>::get(path)
20 .map(|f| f.data)
21 .ok_or_else(|| anyhow!("no asset exists at path {}", path))
22 }
23}
24 
25fn main() -> Result<()> {
26 let app_builder =
27 platform::AppBuilder::new(platform::AppCallbacks::default(), Box::new(ASSETS), None);
28 let _ = app_builder.run(move |ctx| {
29 ctx.add_window(
30 strato_ui::AddWindowOptions {
31 // Set the window background blur radius to 18 pixels.
32 background_blur_radius_pixels: Some(18),
33 ..Default::default()
34 },
35 |_| root_view::BlurredView {},
36 );
37 });
38 
39 Ok(())
40}
41