//! Crab Counter is an app that allows you to keep track of the number of crabs //! you have! 🦀 🦀 🦀 #![feature(min_specialization)] #![feature(type_alias_impl_trait)] use frui::prelude::*; mod misc; use misc::Button; #[derive(ViewWidget)] struct CrabCounter; impl WidgetState for CrabCounter { type State = isize; fn create_state(&self) -> Self::State { 0 } } impl ViewWidget for CrabCounter { fn build<'w>(&'w self, ctx: BuildContext<'w, Self>) -> Self::Widget<'w> { Column::builder() .space_between(60.0) .main_axis_size(MainAxisSize::Max) .cross_axis_size(CrossAxisSize::Max) .main_axis_alignment(MainAxisAlignment::Center) .cross_axis_alignment(CrossAxisAlignment::Center) .children(( Text::new(format!("{} 🦀", *ctx.state())) .size(100.0) .weight(FontWeight::BOLD), Row::builder() .space_between(10.0) // .children(( Button { label: Text::new("+").size(30.), on_click: || *ctx.state_mut() += 1, }, Button { label: Text::new("-").size(30.), on_click: || *ctx.state_mut() -= 1, }, )), )) } } fn main() { run_app(CrabCounter); }