summaryrefslogtreecommitdiffstats
path: root/examples/todos/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/todos/src/main.rs')
-rw-r--r--examples/todos/src/main.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 7a546815..97415475 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -1,7 +1,7 @@
use iced::{
button, scrollable, text_input, Align, Application, Button, Checkbox,
- Column, Command, Container, Element, Font, HorizontalAlignment, Length,
- Row, Scrollable, Settings, Text, TextInput,
+ Clipboard, Column, Command, Container, Element, Font, HorizontalAlignment,
+ Length, Row, Scrollable, Settings, Text, TextInput,
};
use serde::{Deserialize, Serialize};
@@ -58,7 +58,11 @@ impl Application for Todos {
format!("Todos{} - Iced", if dirty { "*" } else { "" })
}
- fn update(&mut self, message: Message) -> Command<Message> {
+ fn update(
+ &mut self,
+ message: Message,
+ _clipboard: &mut Clipboard,
+ ) -> Command<Message> {
match self {
Todos::Loading => {
match message {
@@ -261,8 +265,11 @@ impl Task {
self.completed = completed;
}
TaskMessage::Edit => {
+ let mut text_input = text_input::State::focused();
+ text_input.select_all();
+
self.state = TaskState::Editing {
- text_input: text_input::State::focused(),
+ text_input,
delete_button: button::State::new(),
};
}
@@ -489,7 +496,6 @@ enum LoadError {
#[derive(Debug, Clone)]
enum SaveError {
- DirectoryError,
FileError,
WriteError,
FormatError,
@@ -499,7 +505,7 @@ enum SaveError {
impl SavedState {
fn path() -> std::path::PathBuf {
let mut path = if let Some(project_dirs) =
- directories::ProjectDirs::from("rs", "Iced", "Todos")
+ directories_next::ProjectDirs::from("rs", "Iced", "Todos")
{
project_dirs.data_dir().into()
} else {
@@ -538,7 +544,7 @@ impl SavedState {
if let Some(dir) = path.parent() {
async_std::fs::create_dir_all(dir)
.await
- .map_err(|_| SaveError::DirectoryError)?;
+ .map_err(|_| SaveError::FileError)?;
}
{
@@ -611,7 +617,7 @@ mod style {
background: Some(Background::Color(
Color::from_rgb(0.2, 0.2, 0.7),
)),
- border_radius: 10,
+ border_radius: 10.0,
text_color: Color::WHITE,
..button::Style::default()
}
@@ -627,7 +633,7 @@ mod style {
background: Some(Background::Color(Color::from_rgb(
0.8, 0.2, 0.2,
))),
- border_radius: 5,
+ border_radius: 5.0,
text_color: Color::WHITE,
shadow_offset: Vector::new(1.0, 1.0),
..button::Style::default()