use crate::core::px;
use crate::view::prelude::*;
use crate::widgets::separator::horizontal_separator;
pub struct StatusBar {
left: Vec<AnyElement>,
right: Vec<AnyElement>,
}
impl StatusBar {
pub fn new() -> Self {
Self { left: Vec::new(), right: Vec::new() }
}
pub fn left(mut self, item: impl IntoElement) -> Self {
self.left.push(item.into_element());
self
}
pub fn right(mut self, item: impl IntoElement) -> Self {
self.right.push(item.into_element());
self
}
}
impl Default for StatusBar {
fn default() -> Self {
Self::new()
}
}
impl IntoElement for StatusBar {
fn into_element(self) -> AnyElement {
let group = |items: Vec<AnyElement>| div().flex_row().items_center().gap_3().children(items);
div()
.flex_col()
.w_full()
.h(px(25.0))
.flex_shrink_0()
.bg(Token::Surface)
.child(horizontal_separator())
.child(
div()
.flex_1()
.flex_row()
.items_center()
.justify_between()
.px_3()
.text_xs()
.text_color(Token::TextMuted)
.child(group(self.left))
.child(group(self.right)),
)
.into_element()
}
}