diff options
Diffstat (limited to 'examples/todos')
-rw-r--r-- | examples/todos/src/main.rs | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index b34f71ce..86845f87 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -1,11 +1,10 @@ -use iced::alignment::{self, Alignment}; use iced::keyboard; use iced::widget::{ self, button, center, checkbox, column, container, keyed_column, row, scrollable, text, text_input, Text, }; use iced::window; -use iced::{Element, Font, Length, Subscription, Task as Command}; +use iced::{Center, Element, Fill, Font, Subscription, Task as Command}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; @@ -193,10 +192,10 @@ impl Todos { .. }) => { let title = text("todos") - .width(Length::Fill) + .width(Fill) .size(100) .color([0.5, 0.5, 0.5]) - .horizontal_alignment(alignment::Horizontal::Center); + .align_x(Center); let input = text_input("What needs to be done?", input_value) .id(INPUT_ID.clone()) @@ -240,10 +239,7 @@ impl Todos { .spacing(20) .max_width(800); - scrollable( - container(content).center_x(Length::Fill).padding(40), - ) - .into() + scrollable(container(content).center_x(Fill).padding(40)).into() } } } @@ -343,7 +339,7 @@ impl Task { TaskState::Idle => { let checkbox = checkbox(&self.description, self.completed) .on_toggle(TaskMessage::Completed) - .width(Length::Fill) + .width(Fill) .size(17) .text_shaping(text::Shaping::Advanced); @@ -355,7 +351,7 @@ impl Task { .style(button::text), ] .spacing(20) - .align_items(Alignment::Center) + .align_y(Center) .into() } TaskState::Editing => { @@ -371,14 +367,14 @@ impl Task { button( row![delete_icon(), "Delete"] .spacing(10) - .align_items(Alignment::Center) + .align_y(Center) ) .on_press(TaskMessage::Delete) .padding(10) .style(button::danger) ] .spacing(20) - .align_items(Alignment::Center) + .align_y(Center) .into() } } @@ -405,17 +401,16 @@ fn view_controls(tasks: &[Task], current_filter: Filter) -> Element<Message> { "{tasks_left} {} left", if tasks_left == 1 { "task" } else { "tasks" } ) - .width(Length::Fill), + .width(Fill), row![ filter_button("All", Filter::All, current_filter), filter_button("Active", Filter::Active, current_filter), filter_button("Completed", Filter::Completed, current_filter,), ] - .width(Length::Shrink) .spacing(10) ] .spacing(20) - .align_items(Alignment::Center) + .align_y(Center) .into() } @@ -440,20 +435,15 @@ impl Filter { } fn loading_message<'a>() -> Element<'a, Message> { - center( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .into() + center(text("Loading...").width(Fill).align_x(Center).size(50)).into() } fn empty_message(message: &str) -> Element<'_, Message> { center( text(message) - .width(Length::Fill) + .width(Fill) .size(25) - .horizontal_alignment(alignment::Horizontal::Center) + .align_x(Center) .color([0.7, 0.7, 0.7]), ) .height(200) @@ -467,7 +457,7 @@ fn icon(unicode: char) -> Text<'static> { text(unicode.to_string()) .font(ICONS) .width(20) - .horizontal_alignment(alignment::Horizontal::Center) + .align_x(Center) } fn edit_icon() -> Text<'static> { |