cushy/examples/checkbox.rs
Jonathan Johnson b2fdf06e60
Dynamic now requires PartialEq
This reduces the complexity of operations capable with Dynamic, and also
makes it easier to shortcut deadlocking operations.
2023-11-23 11:53:59 -08:00

20 lines
591 B
Rust

use gooey::value::Dynamic;
use gooey::widget::MakeWidget;
use gooey::widgets::checkbox::{Checkable, CheckboxState};
use gooey::Run;
fn main() -> gooey::Result {
let checkbox_state = Dynamic::new(CheckboxState::Checked);
let label = checkbox_state.map_each(|state| format!("Check Me! Current: {state:?}"));
checkbox_state
.clone()
.into_checkbox(label)
.and("Maybe".into_button().on_click(move |()| {
checkbox_state.set(CheckboxState::Indeterminant);
}))
.into_columns()
.centered()
.expand()
.run()
}