Add program::Preset and emulator::Mode
This commit is contained in:
parent
927d5b7cba
commit
73f5569f28
17 changed files with 305 additions and 39 deletions
|
|
@ -5,6 +5,10 @@ authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
|
|||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[features]
|
||||
test = ["iced/test"]
|
||||
tester = ["test", "iced/tester"]
|
||||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
iced.features = ["tokio", "debug", "time-travel"]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,16 @@ pub fn main() -> iced::Result {
|
|||
#[cfg(not(target_arch = "wasm32"))]
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
iced::application(Todos::new, Todos::update, Todos::view)
|
||||
let todos = iced::application(Todos::new, Todos::update, Todos::view)
|
||||
.subscription(Todos::subscription)
|
||||
.title(Todos::title)
|
||||
.font(Todos::ICON_FONT)
|
||||
.window_size((500.0, 800.0))
|
||||
.run()
|
||||
.window_size((500.0, 800.0));
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
let todos = todos.presets(presets());
|
||||
|
||||
todos.run()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -572,6 +576,39 @@ impl SavedState {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
fn presets() -> impl Iterator<Item = iced::application::Preset<Todos, Message>>
|
||||
{
|
||||
use iced::application::Preset;
|
||||
|
||||
[
|
||||
Preset::new("Empty", || {
|
||||
(
|
||||
Todos::Loading,
|
||||
Command::done(Message::Loaded(Err(LoadError::File))),
|
||||
)
|
||||
}),
|
||||
Preset::new("Basic", || {
|
||||
(
|
||||
Todos::Loaded(State {
|
||||
input_value: "Bake an apple pie".to_owned(),
|
||||
filter: Filter::All,
|
||||
tasks: vec![Task {
|
||||
id: Uuid::new_v4(),
|
||||
description: "Create the universe".to_owned(),
|
||||
completed: false,
|
||||
state: TaskState::Idle,
|
||||
}],
|
||||
dirty: false,
|
||||
saving: false,
|
||||
}),
|
||||
Command::none(),
|
||||
)
|
||||
}),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue