pub fn launch() { // Build a new window let main_window = WindowDesc::<u32,Flex<u32>>::new(ui_builder); // Application state is initially 0 let data = 0_u32; // Launch the window with the initial application state AppLauncher::<u32,Flex<u32>>::with_window(main_window) .use_simple_logger() .launch(data) .expect("launch failed"); } /// Build the UI for the window. The application state consists of 1 value: `count` of type `u32`. fn ui_builder() -> Flex<u32> { // `u32` is the window state // Create a line of text based on a counter value let text = LocalizedString::<u32>::new("hello-counter") .with_arg( "count", // Closure that will fetch the counter value... | data: &u32, _env | (*data).into() ); // Create a label widget to display the text let label = Label::<u32>::new(text); // Create a button widget to increment the counter let button = Button::<u32>::new( "increment", // Closure that will be called when button is tapped... | _ctx, data, _env | *data += 1 ); // Create a column for the UI let mut col = Column::new::<u32>(); // Add the label widget to the column, centered with padding col.add_child::<Align::<u32>>( Align::<u32>::centered( Padding::<u32>::new(5.0, label) ), 1.0 ); // Add the button widget to the column, with padding col.add_child::<Padding::<u32>>( Padding::<u32>::new(5.0, button), 1.0 ); // Return the column containing the label and button widgets col }