Use image::Viewer
in pokedex
example
This commit is contained in:
parent
71de341684
commit
0cdf8d56ee
@ -1,6 +1,6 @@
|
||||
use iced::{
|
||||
button, futures, image, Align, Application, Button, Column, Command,
|
||||
Container, Element, Image, Length, Row, Settings, Text,
|
||||
Container, Element, Length, Row, Settings, Text,
|
||||
};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
@ -112,16 +112,20 @@ struct Pokemon {
|
||||
name: String,
|
||||
description: String,
|
||||
image: image::Handle,
|
||||
image_viewer: image::viewer::State,
|
||||
}
|
||||
|
||||
impl Pokemon {
|
||||
const TOTAL: u16 = 807;
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
fn view(&mut self) -> Element<Message> {
|
||||
Row::new()
|
||||
.spacing(20)
|
||||
.align_items(Align::Center)
|
||||
.push(Image::new(self.image.clone()))
|
||||
.push(image::Viewer::new(
|
||||
&mut self.image_viewer,
|
||||
self.image.clone(),
|
||||
))
|
||||
.push(
|
||||
Column::new()
|
||||
.spacing(20)
|
||||
@ -200,6 +204,7 @@ impl Pokemon {
|
||||
.map(|c| if c.is_control() { ' ' } else { c })
|
||||
.collect(),
|
||||
image,
|
||||
image_viewer: image::viewer::State::new(),
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user