Skip to content

Commit

Permalink
chore: Update i18n example
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Nov 1, 2023
1 parent bfd10ba commit dacf9fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ freya-node-state = { workspace = true }
reqwest = { version = "0.11.22", features = ["json"] }
serde = "1.0.189"
tracing-subscriber = "0.3.17"
dioxus-std = { version = "0.4", features = ["utils", "i18n"] }
dioxus-std = { version = "0.4", features = ["i18n"] }
rand = "0.8.5"
dioxus-router = { workspace = true }
itertools = "0.11.0"
Expand Down
26 changes: 12 additions & 14 deletions examples/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

use std::{
sync::{Arc, Mutex},
time::{Duration, Instant},
time::Instant,
};

use dioxus_std::utils::channel::{use_channel, use_listen_channel};
use freya::{common::EventMessage, prelude::*};
use freya::prelude::*;
use skia_safe::{Color, Data, Paint, Rect, RuntimeEffect};
use tokio::time::sleep;

fn main() {
launch(app);
Expand All @@ -36,22 +34,24 @@ const SHADER: &str = "

fn app(cx: Scope) -> Element {
let platform = use_platform(cx);
let render_channel = use_channel::<()>(cx, 1);

use_listen_channel(cx, &render_channel, move |_| {
to_owned![platform];
async move {
sleep(Duration::from_millis(25)).await;
platform.send(EventMessage::RequestRerender).unwrap();
}
cx.use_hook(|| {
let mut ticker = platform.new_ticker();

cx.spawn(async move {
loop {
ticker.tick().await;
platform.request_animation_frame();
}
});
});

let canvas = use_canvas(cx, (), |_| {
let shader = RuntimeEffect::make_for_shader(SHADER, None).unwrap();
let shader_wrapper = Arc::new(Mutex::new(ShaderWrapper(shader)));
let instant = Instant::now();

to_owned![render_channel, shader_wrapper];
to_owned![shader_wrapper];
Box::new(move |canvas, _, region| {
let shader = shader_wrapper.lock().unwrap();

Expand Down Expand Up @@ -83,8 +83,6 @@ fn app(cx: Scope) -> Element {
),
&paint,
);

render_channel.try_send(()).ok();
})
});

Expand Down

0 comments on commit dacf9fc

Please sign in to comment.