Crates.io | viewbuilder |
lib.rs | viewbuilder |
version | 0.10.0-alpha.5 |
source | src |
created_at | 2023-09-24 00:21:54.369044 |
updated_at | 2024-01-08 21:33:50.653233 |
description | Cross-platform UI framework |
homepage | |
repository | https://github.com/matthunz/viewbuilder |
max_upload_size | |
id | 981623 |
size | 38,385 |
A cross-platform user interface framework for Rust.
Viewbuilder is a modular GUI library that can be used as an entire framework, or with individual parts.
use viewbuilder::{
view,
web::{self, html, Web},
ControlFlow, Model, View,
};
enum Message {
Increment,
Decrement,
}
#[derive(Default)]
struct App {
count: i32,
}
impl Model<Message> for App {
fn handle(&mut self, msg: Message) -> ControlFlow {
match msg {
Message::Decrement => self.count -= 1,
Message::Increment => self.count += 1,
}
ControlFlow::Rebuild
}
}
fn view(model: &App) -> impl View<Web, Message> {
(
format!("High five count: {}", model.count),
view::once(html::button(
html::on_click(|| Message::Increment),
"Up high!",
)),
view::once(html::button(
html::on_click(|| Message::Decrement),
"Down low!",
)),
)
}
fn main() {
web::run(App::default(), view)
}
Instatllation is simple with:
cargo add viewbuilder --features full