use mitsuami_core::{
Children, Display, Element, ElementBuilder, FlexDirection, Length, NodeId, Prop, Ui, UiEvent, View, WidgetKind,
};
use mitsuami_reactive::{IntoValue, Signal};
pub struct Popover(Element);
widget!(Popover);
impl Popover {
pub fn new(shown: Signal<bool>) -> Popover {
let mut element = Element::new(WidgetKind::Popover);
element.prop(shown.into_value(), Prop::PopoverShown);
element.on(move |event| {
if let UiEvent::PopoverShownChanged(on) = event {
shown.set(*on);
}
});
Popover(element).style(|s| {
s.display = Display::Flex;
s.flex_direction = FlexDirection::Column;
})
}
pub fn gap(mut self, gap: impl IntoValue<Length>) -> Popover {
self.0.style_prop(gap.into_value(), |s, v| {
s.row_gap = v;
s.column_gap = v;
});
self
}
pub fn children(mut self, children: impl Children) -> Popover {
self.0.add_children(children);
self
}
pub fn child(self, child: impl View) -> Popover {
self.children(child)
}
#[doc(hidden)]
pub fn __tag(shown: Signal<bool>) -> Popover {
Popover::new(shown)
}
#[doc(hidden)]
pub fn __children<C: Children>(self, children: impl FnOnce() -> C) -> Popover {
self.children(children())
}
}