1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::prelude::*;

pub struct Dialog {}

impl Dialog {
    pub fn new(
        cx: &mut Context,
        is_open: impl Lens<Target = bool>,
        content: impl Fn(&mut Context) + 'static,
    ) -> Handle<Self> {
        Self {}.build(cx, move |cx| {
            Binding::new(cx, is_open, move |cx, is_open| {
                if is_open.get(cx) {
                    (content)(cx);
                }
            })
        })
    }
}

impl View for Dialog {
    fn element(&self) -> Option<&'static str> {
        Some("dialog")
    }
}