Make Row, Column, and Checkbox shrink by default

This commit is contained in:
Héctor Ramón Jiménez 2019-12-30 20:54:04 +01:00
parent 74d01a6957
commit 2ff0e48142
17 changed files with 42 additions and 54 deletions

View file

@ -77,11 +77,8 @@ impl Application for Pokedex {
fn view(&mut self) -> Element<Message> {
let content = match self {
Pokedex::Loading => Column::new().width(Length::Shrink).push(
Text::new("Searching for Pokémon...")
.width(Length::Shrink)
.size(40),
),
Pokedex::Loading => Column::new()
.push(Text::new("Searching for Pokémon...").size(40)),
Pokedex::Loaded { pokemon, search } => Column::new()
.max_width(500)
.spacing(20)
@ -91,14 +88,9 @@ impl Application for Pokedex {
button(search, "Keep searching!").on_press(Message::Search),
),
Pokedex::Errored { try_again, .. } => Column::new()
.width(Length::Shrink)
.spacing(20)
.align_items(Align::End)
.push(
Text::new("Whoops! Something went wrong...")
.width(Length::Shrink)
.size(40),
)
.push(Text::new("Whoops! Something went wrong...").size(40))
.push(button(try_again, "Try again").on_press(Message::Search)),
};
@ -134,10 +126,13 @@ impl Pokemon {
Row::new()
.align_items(Align::Center)
.spacing(20)
.push(Text::new(&self.name).size(30))
.push(
Text::new(&self.name)
.size(30)
.width(Length::Fill),
)
.push(
Text::new(format!("#{}", self.number))
.width(Length::Shrink)
.size(20)
.color([0.5, 0.5, 0.5]),
),