use gtk::prelude::GtkWindowExt;
use relm4::{ComponentParts, ComponentSender, SimpleComponent, gtk};

#[derive(Default)]
pub struct AppModel;

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

    view! {
        gtk::Window {
            set_title: Some("Simple app"),
            set_default_width: 300,
            set_default_height: 100,

            #[local_ref]
            my_box_ref -> gtk::Box {
                gtk::Label {
                    set_label: "This should compile",
                }
            },
        }
    }

    fn init(
        _init: Self::Init,
        _root: Self::Root,
        _sender: ComponentSender<Self>,
    ) -> ComponentParts<Self> {
        let model = Self;

        let my_box = gtk::Box::default();
        let my_box_ref = &my_box;

        let widgets = view_output!();

        ComponentParts { model, widgets }
    }

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