Introduce helper methods for alignment for all widgets

This commit is contained in:
Héctor Ramón Jiménez 2024-07-12 15:11:30 +02:00
parent be06060117
commit f9dd5cbb09
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
45 changed files with 380 additions and 282 deletions

View file

@ -5,8 +5,8 @@ use iced::widget::{
pick_list, row, scrollable, text,
};
use iced::{
color, Alignment, Element, Font, Length, Point, Rectangle, Renderer,
Subscription, Theme,
color, Element, Font, Length, Point, Rectangle, Renderer, Subscription,
Theme,
};
pub fn main() -> iced::Result {
@ -74,7 +74,7 @@ impl Layout {
pick_list(Theme::ALL, Some(&self.theme), Message::ThemeSelected),
]
.spacing(20)
.align_items(Alignment::Center);
.center_y();
let example = center(if self.explain {
self.example.view().explain(color!(0x0000ff))
@ -234,7 +234,7 @@ fn application<'a>() -> Element<'a, Message> {
square(40),
]
.padding(10)
.align_items(Alignment::Center),
.center_y(),
)
.style(|theme| {
let palette = theme.extended_palette();
@ -248,7 +248,7 @@ fn application<'a>() -> Element<'a, Message> {
.spacing(40)
.padding(10)
.width(200)
.align_items(Alignment::Center),
.center_x(),
)
.style(container::rounded_box)
.center_y(Length::Fill);
@ -263,7 +263,7 @@ fn application<'a>() -> Element<'a, Message> {
"The end"
]
.spacing(40)
.align_items(Alignment::Center)
.center_x()
.width(Length::Fill),
)
.height(Length::Fill),