cushy/examples/counter.rs
Jonathan Johnson 79be9a063b
Scroll and Animations
Scroll is only working to the absolute barest of requirements.
2023-11-01 15:15:14 -07:00

24 lines
669 B
Rust

use std::string::ToString;
use gooey::value::Dynamic;
use gooey::widgets::{Button, Label, Scroll, Stack};
use gooey::{widgets, Run};
fn main() -> gooey::Result {
let counter = Dynamic::new(0i32);
let label = counter.map_each(ToString::to_string);
Scroll::new(Stack::rows(widgets![
Label::new(label),
Button::new("+").on_click(counter.with_clone(|counter| {
move |_| {
counter.set(counter.get() + 1);
}
})),
Button::new("-").on_click(counter.with_clone(|counter| {
move |_| {
counter.set(counter.get() - 1);
}
})),
]))
.run()
}