use super::messages::RenderInputMsg;
use super::monitor::MonitorModel;
use gtk::prelude::*;
use relm4::component::AsyncComponentController;
use relm4::{
    component::{AsyncComponent, AsyncController},
    RelmWidgetExt, *,
};

pub struct RenderPanelModel {
    // monitor: Controller<MonitorModel>,
    monitor: AsyncController<MonitorModel>,
}

#[relm4::component(pub)]
impl SimpleComponent for RenderPanelModel {
    type Init = ();
    type Output = ();
    type Input = ();

    view! {
        gtk::Box{
            set_orientation: gtk::Orientation::Horizontal,
            set_hexpand:true,
            set_vexpand:true,
            model.monitor.widget(),
        }
    }

    fn init(
        init: Self::Init,
        root: &Self::Root,
        sender: relm4::ComponentSender<Self>,
    ) -> relm4::ComponentParts<Self> {

        let monitor: AsyncController<MonitorModel> = MonitorModel::builder()
            .launch(())
            .forward(sender.input_sender(), |msg| {});

        let model = RenderPanelModel { monitor };
        let widgets = view_output!();
        ComponentParts { model, widgets }
    }

    fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {}
}
