summaryrefslogtreecommitdiffstats
path: root/examples/todos
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-06 03:06:39 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-06 03:06:39 +0100
commite8316b208705910958152b2ef6c4c5d7110b4e6c (patch)
tree994e72b3f0e852a93012164177ea8d98de116fcf /examples/todos
parent57aed1d5c61a14fa6337e9f838fc519efdd75e06 (diff)
downloadiced-e8316b208705910958152b2ef6c4c5d7110b4e6c.tar.gz
iced-e8316b208705910958152b2ef6c4c5d7110b4e6c.tar.bz2
iced-e8316b208705910958152b2ef6c4c5d7110b4e6c.zip
Allow `todos` example to compile to `wasm32`
Diffstat (limited to 'examples/todos')
-rw-r--r--examples/todos/Cargo.toml4
-rw-r--r--examples/todos/src/main.rs19
2 files changed, 22 insertions, 1 deletions
diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml
index 21acd5d6..cfb8e97d 100644
--- a/examples/todos/Cargo.toml
+++ b/examples/todos/Cargo.toml
@@ -8,9 +8,11 @@ publish = false
[dependencies]
iced = { path = "../.." }
iced_futures = { path = "../../futures", features = ["async-std"] }
-async-std = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
+
+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
+async-std = "1.0"
directories = "2.0"
[package.metadata.deb]
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index bfae5e88..8262b537 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -38,7 +38,12 @@ enum Message {
}
impl Application for Todos {
+ #[cfg(not(target_arch = "wasm32"))]
type Executor = iced_futures::executor::AsyncStd;
+
+ #[cfg(target_arch = "wasm32")]
+ type Executor = iced_futures::executor::WasmBindgen;
+
type Message = Message;
fn new() -> (Todos, Command<Message>) {
@@ -377,6 +382,7 @@ impl Controls {
)
.push(
Row::new()
+ .width(Length::Shrink)
.spacing(10)
.push(filter_button(
all_button,
@@ -493,6 +499,7 @@ enum SaveError {
FormatError,
}
+#[cfg(not(target_arch = "wasm32"))]
impl SavedState {
fn path() -> std::path::PathBuf {
let mut path = if let Some(project_dirs) =
@@ -555,6 +562,18 @@ impl SavedState {
}
}
+// TODO
+#[cfg(target_arch = "wasm32")]
+impl SavedState {
+ async fn load() -> Result<SavedState, LoadError> {
+ Err(LoadError::FileError)
+ }
+
+ async fn save(self) -> Result<(), SaveError> {
+ Err(SaveError::FileError)
+ }
+}
+
mod style {
use iced::{button, Background, Color, Vector};