use cosmic::iced::Subscription;
use cosmic::Element;
use std::any::Any;

pub mod a11y;
pub mod appearance;
pub mod keyboard;
pub mod language;
pub mod layout;
pub mod location;

#[derive(Clone, Debug)]
pub enum Message {
    A11y(a11y::Message),
    Appearance(appearance::Message),
    Keyboard(keyboard::Message),
    Language(language::Message),
    Layout(layout::Message),
    Location(location::Message),
    SetTheme(cosmic::Theme),
}

impl From<Message> for super::Message {
    fn from(message: Message) -> Self {
        super::Message::PageMessage(message)
    }
}

pub trait Page {
    fn as_any(&mut self) -> &mut dyn Any;
    fn title(&self) -> String;

    fn init(&mut self) -> cosmic::Task<Message> {
        cosmic::Task::none()
    }

    fn apply_settings(&mut self) -> cosmic::Task<Message> {
        cosmic::Task::none()
    }

    fn open(&mut self) -> cosmic::Task<Message> {
        cosmic::Task::none()
    }

    fn width(&self) -> f32 {
        640.0
    }

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

    fn optional(&self) -> bool {
        false
    }

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

    fn dialog(&self) -> Option<Element<'_, Message>> {
        None
    }

    fn view(&self) -> Element<'_, Message> {
        cosmic::widget::text::body("TODO").into()
    }

    fn subscription(&self) -> Subscription<Message> {
        Subscription::none()
    }
}
