From fd2cbca34d5c235369e0d8c6634a9f95640945f0 Mon Sep 17 00:00:00 2001 From: Max Coppen <44031065+mxcop@users.noreply.github.com> Date: Wed, 2 Nov 2022 19:13:26 +0100 Subject: [PATCH] wip: updater --- Cargo.toml | 5 ++-- examples/api/src/main.rs | 3 +++ examples/api/src/views/updater.rs | 45 +++++++++++++++++++++++++++++++ src/lib.rs | 2 ++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 examples/api/src/views/updater.rs diff --git a/Cargo.toml b/Cargo.toml index 8c2523a..1032479 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,10 @@ wasm-bindgen-test = "0.3.33" tauri-sys = { path = ".", features = ["all"] } [features] -all = ["app", "clipboard", "event", "mocks", "tauri"] +all = ["app", "clipboard", "event", "mocks", "tauri", "updater"] app = ["dep:semver"] clipboard = [] event = [] mocks = [] -tauri = ["dep:url"] \ No newline at end of file +tauri = ["dep:url"] +updater = [] \ No newline at end of file diff --git a/examples/api/src/main.rs b/examples/api/src/main.rs index c317bcc..c8a2ebc 100644 --- a/examples/api/src/main.rs +++ b/examples/api/src/main.rs @@ -17,6 +17,9 @@ fn Header(cx: Scope) -> View { a(href="/clipboard") { "Clipboard" } + a(href="/updater") { + "Updater" + } a(href="/communication") { "Communication" } diff --git a/examples/api/src/views/updater.rs b/examples/api/src/views/updater.rs new file mode 100644 index 0000000..53c844c --- /dev/null +++ b/examples/api/src/views/updater.rs @@ -0,0 +1,45 @@ +use sycamore::prelude::*; +use tauri_sys::clipboard::{read_text, write_text}; + +#[component] +pub fn Updater(cx: Scope) -> View { + // let text = create_signal(cx, "clipboard message".to_string()); + + // let write = move |_| { + // sycamore::futures::spawn_local_scoped(cx, async move { + // write_text(&text.get()).await + // // .then(() => { + // // onMessage('Wrote to the clipboard') + // // }) + // // .catch(onMessage) + // }); + // }; + + // let read = |_| { + // sycamore::futures::spawn_local(async move { + // let text = read_text().await; + + // log::info!("Read text from clipboard {:?}", text); + // // readText() + // // .then((contents) => { + // // onMessage(`Clipboard contents: ${contents}`) + // // }) + // // .catch(onMessage) + // }); + // }; + + // view! { cx, + // div(class="flex gap-1") { + // input(class="grow input",placeholder="Text to write to the clipboard",bind:value=text) + // button(class="btn",type="button",on:click=write) { + // "Write" + // } + // button(class="btn",type="button",on:click=read) { + // "Read" + // } + // } + // } + view! { cx, + div(class="updater") { } + } +} diff --git a/src/lib.rs b/src/lib.rs index 20d4fbd..ace5379 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,8 @@ pub mod event; pub mod mocks; #[cfg(feature = "tauri")] pub mod tauri; +#[cfg(feature = "updater")] +pub mod updater; #[derive(Debug, thiserror::Error)] pub enum Error {