1use bevy::prelude::*;
2use bevy_compose::{compose, flex, handler_system, lazy, Compose, Composer};
3
4#[derive(Resource)]
5struct Count(i32);
6
7fn ui(count: Res<Count>) -> impl Compose {
8 (
9 format!("High five count: {}", count.0),
10 flex("Up high!").on_click(|mut count: ResMut<Count>| count.0 += 1),
11 flex("Down low!").on_click(|mut count: ResMut<Count>| count.0 -= 1),
12 )
13}
14
15fn main() {
16 let mut app = App::new();
17
18 app.world.insert_resource(Count(0));
19 app.world.spawn(Composer::new(ui));
20 app.world
21 .spawn((Camera2dBundle::default(), IsDefaultUiCamera));
22
23 app.add_plugins(DefaultPlugins)
24 .add_systems(Update, (compose, handler_system))
25 .run();
26}