use gtk::prelude::*;
use relm4::{
    factory::FactoryView,
    gtk,
    prelude::{DynamicIndex, FactoryComponent},
    FactorySender,
};

use super::Msg;

#[derive(Debug)]
pub enum TestMsg {
    Delete,
    MoveUp,
    MoveDown,
    Add,
}

pub struct BottomBarModel {
    icon: String,
    msg: TestMsg,
}

impl BottomBarModel {
    pub fn new(icon: String) -> Self {
        Self {
            icon,
            msg: TestMsg::Add,
        }
    }
}

#[relm4::factory(pub)]
impl FactoryComponent for BottomBarModel {
    type ParentWidget = gtk::Box;
    type ParentInput = Msg;
    type Input = ();
    type Output = TestMsg;
    type Init = BottomBarModel;
    type CommandOutput = ();

    view! {
        #[root]
        gtk::Box{
            gtk::Button{
                set_icon_name=self.icon.as_str(),
            }
        }

    }

    fn init_model(init: Self::Init, index: &DynamicIndex, sender: FactorySender<Self>) -> Self {
        init
    }

    fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
    }

    fn forward_to_parent(_output: Self::Output) -> Option<Self::ParentInput> {
        Some(match _output {
            _ => Msg::None
        })

    }

}
