Feat: webview example

This commit is contained in:
Jonathan Kelley committed 2021-01-21 11:10:31 -05:00
1 parent 9c01736895
commit 7730fd4a8c
7 files changed
+122 -11

No files matched your search

+6 -3
View File
@@ -12,6 +12,7 @@ log = "0.4.1"
dioxus = { path = "../packages/dioxus" }
dioxus-ssr = { path = "../packages/ssr" }
rand = "0.8.2"
anyhow = "*"
[dev-dependencies]
@@ -22,9 +23,7 @@ tide = { version = "0.15.0" }
# For the doc generator
pulldown-cmark = { version = "0.8.0", default-features = false }
anyhow = "*"
dioxus-webview = { path = "../packages/webview", version = "0.0.0" }
[lib]
path = "common.rs"
@@ -48,3 +47,7 @@ name = "router"
[[example]]
path = "fc_macro.rs"
name = "fc_macro"
[[example]]
path = "webview.rs"
name = "webview"
+23
View File
@@ -0,0 +1,23 @@
use dioxus::prelude::*;
fn main() {
let app = dioxus_webview::new::<()>(|ctx| {
let (count, set_count) = use_state(ctx, || 0);
html! {
<div>
<h1> "Dioxus Desktop Demo" </h1>
<p> "Count is {count}"</p>
<button onclick=|_| set_count(count + 1) >
"Click to increment"
</button>
</div>
}
});
app.launch(());
}
fn use_state<T, G>(ctx: &mut Context<G>, init: impl Fn() -> T) -> (T, impl Fn(T)) {
let g = init();
(g, |_| {})
}