From beb45f337e0002d71e8faac9b88947f82ce03556 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Mon, 20 Nov 2023 02:40:38 -0500 Subject: [PATCH] Update README --- README.md | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f5ecfad..298cbc3 100644 --- a/README.md +++ b/README.md @@ -24,29 +24,28 @@ Cross-platform user interface framework for Rust. This crate provides a moduler GUI library that can be used as an entire framework, or with individual parts. -## Dioxus support ```rust -fn app(cx: Scope) -> Element { - cx.render(rsx! { text { font_size: 100., "Hello World!" } }) +enum Message { + Increment, + Decrement, } -``` -## HTML-like API -```rust -viewbuilder::transaction(|ui| { - ui.insert( - Text::builder() - .font_size(100.) - .color(Color4f::new(1., 0., 0., 1.)) - .on_click(|text| { - viewbuilder::transaction(move |ui| ui[text].set_content(0, "Clicked!")) - }) - .content("Hello World!") - .build(), - ); -}); +fn app<'a>(bump: &'a Bump, count: &mut i32) -> impl View<'a, Message> { + LinearLayout::new(( + format_in!(bump, "High five count: {}", *count), + LinearLayout::new(( + Text::new("Up high!").on_click(Message::Increment), + Text::new("Down low!").on_click(Message::Decrement), + )), + )) +} -viewbuilder::run(); +fn main() { + viewbuilder::run(0, app, |count: &mut i32, msg| match msg { + Message::Increment => *count += 1, + Message::Decrement => *count -= 1, + }) +} ``` ## Features