diff options
author | 2024-07-12 15:11:30 +0200 | |
---|---|---|
committer | 2024-07-12 15:14:43 +0200 | |
commit | f9dd5cbb099bbe44a57b6369be54a442363b7a8d (patch) | |
tree | fe16084bc47faadc32d698aa446ea202f7949a4c /examples/todos | |
parent | be06060117da061ad8cad94ab0830c06def6b147 (diff) | |
download | iced-f9dd5cbb099bbe44a57b6369be54a442363b7a8d.tar.gz iced-f9dd5cbb099bbe44a57b6369be54a442363b7a8d.tar.bz2 iced-f9dd5cbb099bbe44a57b6369be54a442363b7a8d.zip |
Introduce helper methods for alignment for all widgets
Diffstat (limited to 'examples/todos')
-rw-r--r-- | examples/todos/src/main.rs | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index b34f71ce..af651ee2 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -1,4 +1,3 @@ -use iced::alignment::{self, Alignment}; use iced::keyboard; use iced::widget::{ self, button, center, checkbox, column, container, keyed_column, row, @@ -196,7 +195,7 @@ impl Todos { .width(Length::Fill) .size(100) .color([0.5, 0.5, 0.5]) - .horizontal_alignment(alignment::Horizontal::Center); + .center_x(); let input = text_input("What needs to be done?", input_value) .id(INPUT_ID.clone()) @@ -355,7 +354,7 @@ impl Task { .style(button::text), ] .spacing(20) - .align_items(Alignment::Center) + .center_y() .into() } TaskState::Editing => { @@ -369,16 +368,14 @@ impl Task { row![ text_input, button( - row![delete_icon(), "Delete"] - .spacing(10) - .align_items(Alignment::Center) + row![delete_icon(), "Delete"].spacing(10).center_y() ) .on_press(TaskMessage::Delete) .padding(10) .style(button::danger) ] .spacing(20) - .align_items(Alignment::Center) + .center_y() .into() } } @@ -415,7 +412,7 @@ fn view_controls(tasks: &[Task], current_filter: Filter) -> Element<Message> { .spacing(10) ] .spacing(20) - .align_items(Alignment::Center) + .center_y() .into() } @@ -440,12 +437,7 @@ impl Filter { } fn loading_message<'a>() -> Element<'a, Message> { - center( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .into() + center(text("Loading...").center_x().size(50)).into() } fn empty_message(message: &str) -> Element<'_, Message> { @@ -453,7 +445,7 @@ fn empty_message(message: &str) -> Element<'_, Message> { text(message) .width(Length::Fill) .size(25) - .horizontal_alignment(alignment::Horizontal::Center) + .center_x() .color([0.7, 0.7, 0.7]), ) .height(200) @@ -464,10 +456,7 @@ 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) - .horizontal_alignment(alignment::Horizontal::Center) + text(unicode.to_string()).font(ICONS).width(20).center_x() } fn edit_icon() -> Text<'static> { |