Allow todos example to compile to wasm32
This commit is contained in:
parent
57aed1d5c6
commit
e8316b2087
@ -8,9 +8,11 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
iced = { path = "../.." }
|
iced = { path = "../.." }
|
||||||
iced_futures = { path = "../../futures", features = ["async-std"] }
|
iced_futures = { path = "../../futures", features = ["async-std"] }
|
||||||
async-std = "1.0"
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
async-std = "1.0"
|
||||||
directories = "2.0"
|
directories = "2.0"
|
||||||
|
|
||||||
[package.metadata.deb]
|
[package.metadata.deb]
|
||||||
|
|||||||
@ -38,7 +38,12 @@ enum Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Application for Todos {
|
impl Application for Todos {
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
type Executor = iced_futures::executor::AsyncStd;
|
type Executor = iced_futures::executor::AsyncStd;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
type Executor = iced_futures::executor::WasmBindgen;
|
||||||
|
|
||||||
type Message = Message;
|
type Message = Message;
|
||||||
|
|
||||||
fn new() -> (Todos, Command<Message>) {
|
fn new() -> (Todos, Command<Message>) {
|
||||||
@ -377,6 +382,7 @@ impl Controls {
|
|||||||
)
|
)
|
||||||
.push(
|
.push(
|
||||||
Row::new()
|
Row::new()
|
||||||
|
.width(Length::Shrink)
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
.push(filter_button(
|
.push(filter_button(
|
||||||
all_button,
|
all_button,
|
||||||
@ -493,6 +499,7 @@ enum SaveError {
|
|||||||
FormatError,
|
FormatError,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
impl SavedState {
|
impl SavedState {
|
||||||
fn path() -> std::path::PathBuf {
|
fn path() -> std::path::PathBuf {
|
||||||
let mut path = if let Some(project_dirs) =
|
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 {
|
mod style {
|
||||||
use iced::{button, Background, Color, Vector};
|
use iced::{button, Background, Color, Vector};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user