Render status bar

Co-Authored-By: Antonio <me@as-cii.com>
This commit is contained in:
Conrad Irwin 2023-11-02 11:18:11 -06:00
parent 803d2b6710
commit 8f0f5a9ba1
3 changed files with 53 additions and 9 deletions

View file

@ -1,7 +1,11 @@
use std::any::TypeId;
use crate::{ItemHandle, Pane};
use gpui2::{AnyView, Render, Subscription, View, ViewContext, WindowContext};
use gpui2::{
div, AnyView, Component, Div, Element, ParentElement, Render, Styled, Subscription, View,
ViewContext, WindowContext,
};
use theme2::ActiveTheme;
use util::ResultExt;
pub trait StatusItemView: Render {
@ -29,6 +33,41 @@ pub struct StatusBar {
_observe_active_pane: Subscription,
}
impl Render for StatusBar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
div()
.py_0p5()
.px_1()
.flex()
.items_center()
.justify_between()
.w_full()
.bg(cx.theme().colors().status_bar)
.child(self.render_left_tools(cx))
.child(self.render_right_tools(cx))
}
}
impl StatusBar {
fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
div()
.flex()
.items_center()
.gap_1()
.children(self.left_items.iter().map(|item| item.to_any()))
}
fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
div()
.flex()
.items_center()
.gap_2()
.children(self.right_items.iter().map(|item| item.to_any()))
}
}
// todo!()
// impl View for StatusBar {
// fn ui_name() -> &'static str {