diff options
Diffstat (limited to 'examples/todos/src/main.rs')
-rw-r--r-- | examples/todos/src/main.rs | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index af651ee2..86845f87 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -4,7 +4,7 @@ use iced::widget::{ 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}; @@ -192,10 +192,10 @@ impl Todos { .. }) => { let title = text("todos") - .width(Length::Fill) + .width(Fill) .size(100) .color([0.5, 0.5, 0.5]) - .center_x(); + .align_x(Center); let input = text_input("What needs to be done?", input_value) .id(INPUT_ID.clone()) @@ -239,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() } } } @@ -342,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); @@ -354,7 +351,7 @@ impl Task { .style(button::text), ] .spacing(20) - .center_y() + .align_y(Center) .into() } TaskState::Editing => { @@ -368,14 +365,16 @@ impl Task { row![ text_input, button( - row![delete_icon(), "Delete"].spacing(10).center_y() + row![delete_icon(), "Delete"] + .spacing(10) + .align_y(Center) ) .on_press(TaskMessage::Delete) .padding(10) .style(button::danger) ] .spacing(20) - .center_y() + .align_y(Center) .into() } } @@ -402,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) - .center_y() + .align_y(Center) .into() } @@ -437,15 +435,15 @@ impl Filter { } fn loading_message<'a>() -> Element<'a, Message> { - center(text("Loading...").center_x().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) - .center_x() + .align_x(Center) .color([0.7, 0.7, 0.7]), ) .height(200) @@ -456,7 +454,10 @@ fn empty_message(message: &str) -> Element<'_, Message> { const ICONS: Font = Font::with_name("Iced-Todos-Icons"); fn icon(unicode: char) -> Text<'static> { - text(unicode.to_string()).font(ICONS).width(20).center_x() + text(unicode.to_string()) + .font(ICONS) + .width(20) + .align_x(Center) } fn edit_icon() -> Text<'static> { |