use frui::prelude::*;
use rand::Rng;
#[derive(ViewWidget)]
pub struct RandomState;
impl WidgetState for RandomState {
type State = usize;
fn create_state<'a>(&'a self) -> Self::State {
rand::thread_rng().gen()
}
}
impl ViewWidget for RandomState {
fn build<'w>(&'w self, ctx: BuildContext<'w, Self>) -> Self::Widget<'w> {
Text::new(ctx.state().to_string())
}
}
#[derive(ViewWidget)]
pub struct ChangesOnRebuild;
impl ViewWidget for ChangesOnRebuild {
fn build<'w>(&'w self, _: BuildContext<'w, Self>) -> Self::Widget<'w> {
Text::new(rand::thread_rng().gen::<usize>().to_string())
}
}