Re-export variants of Length and alignment types

This commit is contained in:
Héctor Ramón Jiménez 2024-07-12 18:12:34 +02:00
parent f9dd5cbb09
commit 76737351ea
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
51 changed files with 255 additions and 395 deletions

View file

@ -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> {