Use image::Viewer in pokedex example
This commit is contained in:
parent
71de341684
commit
0cdf8d56ee
1 changed files with 8 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use iced::{
|
use iced::{
|
||||||
button, futures, image, Align, Application, Button, Column, Command,
|
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 {
|
pub fn main() -> iced::Result {
|
||||||
|
|
@ -112,16 +112,20 @@ struct Pokemon {
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
image: image::Handle,
|
image: image::Handle,
|
||||||
|
image_viewer: image::viewer::State,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pokemon {
|
impl Pokemon {
|
||||||
const TOTAL: u16 = 807;
|
const TOTAL: u16 = 807;
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&mut self) -> Element<Message> {
|
||||||
Row::new()
|
Row::new()
|
||||||
.spacing(20)
|
.spacing(20)
|
||||||
.align_items(Align::Center)
|
.align_items(Align::Center)
|
||||||
.push(Image::new(self.image.clone()))
|
.push(image::Viewer::new(
|
||||||
|
&mut self.image_viewer,
|
||||||
|
self.image.clone(),
|
||||||
|
))
|
||||||
.push(
|
.push(
|
||||||
Column::new()
|
Column::new()
|
||||||
.spacing(20)
|
.spacing(20)
|
||||||
|
|
@ -200,6 +204,7 @@ impl Pokemon {
|
||||||
.map(|c| if c.is_control() { ' ' } else { c })
|
.map(|c| if c.is_control() { ' ' } else { c })
|
||||||
.collect(),
|
.collect(),
|
||||||
image,
|
image,
|
||||||
|
image_viewer: image::viewer::State::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue