wip: working example page

This commit is contained in:
Max Coppen 2022-11-02 22:45:45 +01:00
parent fd2cbca34d
commit cdad6dd9ec
3 changed files with 35 additions and 34 deletions

View file

@ -18,7 +18,7 @@ fn Header<G: Html>(cx: Scope) -> View<G> {
"Clipboard" "Clipboard"
} }
a(href="/updater") { a(href="/updater") {
"Updater" "Updater"
} }
a(href="/communication") { a(href="/communication") {
"Communication" "Communication"

View file

@ -1,6 +1,7 @@
mod app; mod app;
mod clipboard; mod clipboard;
mod communication; mod communication;
mod updater;
mod welcome; mod welcome;
use sycamore::view::View; use sycamore::view::View;
@ -15,6 +16,8 @@ pub enum Page {
Clipboard, Clipboard,
#[to("/communication")] #[to("/communication")]
Communication, Communication,
#[to("/updater")]
Updater,
#[not_found] #[not_found]
NotFound NotFound
} }
@ -24,6 +27,7 @@ pub fn switch<G: Html>(cx: Scope, route: &ReadSignal<Page>) -> View<G> {
Page::App => app::App(cx), Page::App => app::App(cx),
Page::Clipboard => clipboard::Clipboard(cx), Page::Clipboard => clipboard::Clipboard(cx),
Page::Communication => communication::Communication(cx), Page::Communication => communication::Communication(cx),
Page::Updater => updater::Updater(cx),
Page::NotFound => welcome::Welcome(cx) Page::NotFound => welcome::Welcome(cx)
} }
} }

View file

@ -3,43 +3,40 @@ use tauri_sys::clipboard::{read_text, write_text};
#[component] #[component]
pub fn Updater<G: Html>(cx: Scope) -> View<G> { pub fn Updater<G: Html>(cx: Scope) -> View<G> {
// let text = create_signal(cx, "clipboard message".to_string()); let text = create_signal(cx, "clipboard message".to_string());
// let write = move |_| { let write = move |_| {
// sycamore::futures::spawn_local_scoped(cx, async move { sycamore::futures::spawn_local_scoped(cx, async move {
// write_text(&text.get()).await write_text(&text.get()).await
// // .then(() => { // .then(() => {
// // onMessage('Wrote to the clipboard') // onMessage('Wrote to the clipboard')
// // }) // })
// // .catch(onMessage) // .catch(onMessage)
// }); });
// }; };
// let read = |_| { let read = |_| {
// sycamore::futures::spawn_local(async move { sycamore::futures::spawn_local(async move {
// let text = read_text().await; let text = read_text().await;
// log::info!("Read text from clipboard {:?}", text); log::info!("Read text from clipboard {:?}", text);
// // readText() // readText()
// // .then((contents) => { // .then((contents) => {
// // onMessage(`Clipboard contents: ${contents}`) // onMessage(`Clipboard contents: ${contents}`)
// // }) // })
// // .catch(onMessage) // .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, view! { cx,
div(class="updater") { } 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"
}
}
} }
} }