remove typed stuff / just specify rsc if needed
This commit is contained in:
@@ -2,7 +2,8 @@ use cosmic_text::Family;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use winit::event::WindowEvent;
|
||||
|
||||
iris::state_prelude!(DefaultRsc<Client>);
|
||||
use iris::prelude::*;
|
||||
type ClientRsc = DefaultRsc<Client>;
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<Client>::run();
|
||||
@@ -119,6 +120,7 @@ impl DefaultAppState for Client {
|
||||
texts(rsc).push(msg_box);
|
||||
})
|
||||
.add(rsc);
|
||||
|
||||
let text_edit_scroll = (
|
||||
msg_area.height(rest(1)),
|
||||
(
|
||||
@@ -126,8 +128,8 @@ impl DefaultAppState for Client {
|
||||
(
|
||||
add_text.width(rest(1)),
|
||||
Rect::new(Color::GREEN)
|
||||
.on(CursorSense::click(), move |ctx, rsc| {
|
||||
rsc.run_event::<Submit>(add_text, &mut (), ctx.state);
|
||||
.on(CursorSense::click(), move |ctx, rsc: &mut ClientRsc| {
|
||||
rsc.run_event::<Submit>(add_text, (), ctx.state);
|
||||
})
|
||||
.sized((40, 40)),
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use iris::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
||||
iris::state_prelude!(DefaultRsc<State>);
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<State>::run();
|
||||
}
|
||||
@@ -14,17 +13,15 @@ struct State {
|
||||
impl DefaultAppState for State {
|
||||
fn new(ui_state: DefaultUiState, rsc: &mut DefaultRsc<Self>, _: Proxy<Self::Event>) -> Self {
|
||||
let rect = rect(Color::RED).add(rsc);
|
||||
rect.on(CursorSense::click(), move |_, rsc| {
|
||||
rsc.tasks.spawn(async move |ctx| {
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
ctx.update(move |_, rsc| {
|
||||
let rect = rect(rsc);
|
||||
if rect.color == Color::RED {
|
||||
rect.color = Color::GREEN;
|
||||
} else {
|
||||
rect.color = Color::RED;
|
||||
}
|
||||
});
|
||||
rect.task_on(CursorSense::click(), async move |mut ctx| {
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
ctx.task.update(move |_, rsc| {
|
||||
let rect = rect(rsc);
|
||||
if rect.color == Color::RED {
|
||||
rect.color = Color::GREEN;
|
||||
} else {
|
||||
rect.color = Color::RED;
|
||||
}
|
||||
});
|
||||
})
|
||||
.set_root(rsc);
|
||||
|
||||
Reference in New Issue
Block a user