toolbar.rs

 1use crate::prelude::*;
 2use crate::theme;
 3
 4#[derive(Clone)]
 5pub struct ToolbarItem {}
 6
 7#[derive(Element)]
 8pub struct Toolbar<V: 'static> {
 9    left_items: HackyChildren<V>,
10    left_items_payload: HackyChildrenPayload,
11    right_items: HackyChildren<V>,
12    right_items_payload: HackyChildrenPayload,
13}
14
15impl<V: 'static> Toolbar<V> {
16    pub fn new(
17        left_items: HackyChildren<V>,
18        left_items_payload: HackyChildrenPayload,
19        right_items: HackyChildren<V>,
20        right_items_payload: HackyChildrenPayload,
21    ) -> Self {
22        Self {
23            left_items,
24            left_items_payload,
25            right_items,
26            right_items_payload,
27        }
28    }
29
30    fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
31        let theme = theme(cx);
32
33        div()
34            .fill(theme.highest.base.default.background)
35            .p_2()
36            .flex()
37            .justify_between()
38            .child(
39                div()
40                    .flex()
41                    .children_any((self.left_items)(cx, self.left_items_payload.as_ref())),
42            )
43            .child(
44                div()
45                    .flex()
46                    .children_any((self.right_items)(cx, self.right_items_payload.as_ref())),
47            )
48    }
49}