Add Toolbar component
This commit is contained in:
@@ -10,6 +10,7 @@ mod status_bar;
|
||||
mod tab;
|
||||
mod tab_bar;
|
||||
mod terminal;
|
||||
mod toolbar;
|
||||
mod workspace;
|
||||
|
||||
pub use assistant_panel::*;
|
||||
@@ -24,4 +25,5 @@ pub use status_bar::*;
|
||||
pub use tab::*;
|
||||
pub use tab_bar::*;
|
||||
pub use terminal::*;
|
||||
pub use toolbar::*;
|
||||
pub use workspace::*;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
use crate::prelude::*;
|
||||
use crate::theme;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ToolbarItem {}
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct Toolbar<S: 'static + Send + Sync> {
|
||||
left_items: HackyChildren<S>,
|
||||
left_items_payload: HackyChildrenPayload,
|
||||
right_items: HackyChildren<S>,
|
||||
right_items_payload: HackyChildrenPayload,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Toolbar<S> {
|
||||
pub fn new(
|
||||
left_items: HackyChildren<S>,
|
||||
left_items_payload: HackyChildrenPayload,
|
||||
right_items: HackyChildren<S>,
|
||||
right_items_payload: HackyChildrenPayload,
|
||||
) -> Self {
|
||||
Self {
|
||||
left_items,
|
||||
left_items_payload,
|
||||
right_items,
|
||||
right_items_payload,
|
||||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
.fill(theme.highest.base.default.background)
|
||||
.p_2()
|
||||
.flex()
|
||||
.justify_between()
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.children_any((self.left_items)(cx, self.left_items_payload.as_ref())),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.children_any((self.right_items)(cx, self.right_items_payload.as_ref())),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user