2021-01-22 15:50:16 -05:00
|
|
|
//! Example: Webview Renderer
|
2021-01-26 14:02:35 -05:00
|
|
|
//! -------------------------
|
2021-01-22 15:50:16 -05:00
|
|
|
//!
|
|
|
|
//! This example shows how to use the dioxus_webview crate to build a basic desktop application.
|
|
|
|
//!
|
|
|
|
//! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
|
|
|
|
//! 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 11:09:38 -04:00
|
|
|
//!
|
|
|
|
//! Currently, NodeRefs won't work properly, but all other event functionality will.
|
2021-01-22 15:50:16 -05:00
|
|
|
|
2021-01-21 11:10:31 -05:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
2021-06-17 18:00:32 -04:00
|
|
|
fn main() {
|
2021-07-08 09:29:12 -04:00
|
|
|
dioxus::desktop::launch(App, |c| c);
|
2021-06-24 11:09:38 -04:00
|
|
|
}
|
2021-01-22 15:50:16 -05:00
|
|
|
|
2021-06-24 11:09:38 -04:00
|
|
|
static App: FC<()> = |cx| {
|
2021-07-08 10:17:51 -04:00
|
|
|
let mut count = use_state(cx, || 0);
|
2021-06-24 11:09:38 -04:00
|
|
|
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
2021-07-08 12:01:31 -04:00
|
|
|
h1 { "Hifive counter: {count}" }
|
|
|
|
button { onclick: move |_| count += 1, "Up high!" }
|
|
|
|
button { onclick: move |_| count -= 1, "Down low!" }
|
2021-06-24 11:09:38 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|