use crate::fl;
use cosmic::iced::{Alignment, Length};
use cosmic::{cosmic_theme, widget};
use std::any::Any;

static SCREENSHOT: &[u8] = include_bytes!("../../res/workspaces.svg");

pub struct Page {
    handle: widget::svg::Handle,
}

impl Default for Page {
    fn default() -> Self {
        Self {
            handle: widget::svg::Handle::from_memory(SCREENSHOT),
        }
    }
}

impl super::Page for Page {
    fn title(&self) -> String {
        fl!("workflow-page")
    }

    fn as_any(&mut self) -> &mut dyn Any {
        self
    }

    fn skippable(&self) -> bool {
        true
    }

    fn view(&self) -> cosmic::Element<'_, super::Message> {
        let cosmic_theme::Spacing { space_s, .. } = cosmic::theme::spacing();

        let description = widget::text::body(fl!("workflow-page", "description"))
            .align_x(cosmic::iced::Alignment::Center)
            .width(Length::Fill);

        widget::column::with_capacity(2)
            .push(description)
            .push(widget::svg(self.handle.clone()).width(Length::Fill))
            .align_x(Alignment::Center)
            .spacing(space_s)
            .into()
    }
}
