diff --git a/src/main.rs b/src/main.rs index 14febde..dfc0ef0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,8 @@ enum Message { struct State { image: Option, image_display: Option, + + error: Option, } impl State { fn new() -> (Self, Task) { @@ -33,25 +35,35 @@ impl State { .into_rgba8(), ) }), + + error: None, }; let allocate_image = state.allocate_image(); (state, allocate_image) } fn view(&self) -> Element<'_, Message, Theme, Renderer> { - if let Some(allocation) = self.image_display.as_ref() { - widget::image::viewer(allocation.handle().clone()) - .width(Length::Fill) - .height(Length::Fill) - .into() - } else { - widget::container(widget::text(include_str!("usage.txt"))) - .height(Length::Fill) - .width(Length::Fill) - .align_x(Alignment::Center) - .align_y(Alignment::Center) - .into() - } + widget::column([ + if let Some(allocation) = self.image_display.as_ref() { + widget::image::viewer(allocation.handle().clone()) + .width(Length::Fill) + .height(Length::Fill) + .into() + } else { + widget::container(widget::text(include_str!("usage.txt"))) + .height(Length::Fill) + .width(Length::Fill) + .align_x(Alignment::Center) + .align_y(Alignment::Center) + .into() + }, + if let Some(error) = self.error.as_ref() { + widget::text(error).style(widget::text::danger).into() + } else { + widget::space().into() + }, + ]) + .into() } fn update(&mut self, message: Message) -> Task { match message {