2021-01-22 20:50:16 +00:00
|
|
|
//! Example: Webview Renderer
|
2021-01-26 19:02:35 +00:00
|
|
|
//! -------------------------
|
2021-01-22 20:50:16 +00:00
|
|
|
//!
|
2021-07-16 04:27:06 +00:00
|
|
|
//! This example shows how to use the dioxus_desktop crate to build a basic desktop application.
|
2021-01-22 20:50:16 +00:00
|
|
|
//!
|
2021-07-16 04:27:06 +00:00
|
|
|
//! Under the hood, the dioxus_desktop crate bridges a native Dioxus VirtualDom with a custom prebuit application running
|
2021-01-22 20:50:16 +00:00
|
|
|
//! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
|
|
|
|
//! into the native VDom instance.
|
2021-06-24 15:09:38 +00:00
|
|
|
//!
|
|
|
|
//! Currently, NodeRefs won't work properly, but all other event functionality will.
|
2021-01-22 20:50:16 +00:00
|
|
|
|
2021-01-21 16:10:31 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
2021-06-17 22:00:32 +00:00
|
|
|
fn main() {
|
2021-07-24 06:52:05 +00:00
|
|
|
env_logger::init();
|
2021-07-08 13:29:12 +00:00
|
|
|
dioxus::desktop::launch(App, |c| c);
|
2021-06-24 15:09:38 +00:00
|
|
|
}
|
2021-01-22 20:50:16 +00:00
|
|
|
|
2021-06-24 15:09:38 +00:00
|
|
|
static App: FC<()> = |cx| {
|
2021-07-08 14:17:51 +00:00
|
|
|
let mut count = use_state(cx, || 0);
|
2021-06-24 15:09:38 +00:00
|
|
|
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
2021-07-08 16:01:31 +00:00
|
|
|
h1 { "Hifive counter: {count}" }
|
|
|
|
button { onclick: move |_| count += 1, "Up high!" }
|
|
|
|
button { onclick: move |_| count -= 1, "Down low!" }
|
2021-06-24 15:09:38 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|