fix: images not unloading
This commit is contained in:
parent
4cb52996e2
commit
7db44a3225
1 changed files with 7 additions and 12 deletions
|
|
@ -73,18 +73,13 @@ impl State {
|
|||
fn view(&self) -> Element<'_, Message, Theme, Renderer> {
|
||||
widget::scrollable(
|
||||
widget::grid(self.images.iter().map(|(path, opt_handle)| {
|
||||
opt_handle.as_ref().map_or_else(
|
||||
|| {
|
||||
widget::sensor(widget::space())
|
||||
widget::sensor(opt_handle.as_ref().map_or_else(
|
||||
|| Element::from(widget::space()),
|
||||
|handle| widget::image(handle).into(),
|
||||
))
|
||||
.on_show(|_size| Message::LoadImage(path.clone()))
|
||||
.into()
|
||||
},
|
||||
|handle| {
|
||||
widget::sensor(widget::image(handle))
|
||||
.on_hide(Message::UnloadImage(path.clone()))
|
||||
.into()
|
||||
},
|
||||
)
|
||||
}))
|
||||
.fluid(500)
|
||||
.spacing(0),
|
||||
|
|
|
|||
Loading…
Reference in a new issue