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

@ -1,6 +1,6 @@
use iced::futures;
use iced::widget::{self, center, column, image, row, text};
use iced::{Alignment, Element, Length, Task};
use iced::{Element, Length, Task};
pub fn main() -> iced::Result {
iced::application(Pokedex::title, Pokedex::update, Pokedex::view)
@ -74,13 +74,13 @@ impl Pokedex {
]
.max_width(500)
.spacing(20)
.align_items(Alignment::End),
.align_right(),
Pokedex::Errored => column![
text("Whoops! Something went wrong...").size(40),
button("Try again").on_press(Message::Search)
]
.spacing(20)
.align_items(Alignment::End),
.align_right(),
};
center(content).into()
@ -106,14 +106,14 @@ impl Pokemon {
text(&self.name).size(30).width(Length::Fill),
text!("#{}", self.number).size(20).color([0.5, 0.5, 0.5]),
]
.align_items(Alignment::Center)
.center_y()
.spacing(20),
self.description.as_ref(),
]
.spacing(20),
]
.spacing(20)
.align_items(Alignment::Center)
.center_y()
.into()
}