use gpui::{div, prelude::*}; use crate::dashboard; use crate::query; use crate::theme; use crate::titlebar; use crate::{api, app}; pub struct Global { pub safe_area: gpui::Bounds, pub current_theme: theme::Theme, } pub struct Chrome {} impl Chrome { pub fn new(window: &mut gpui::Window, cx: &mut gpui::Context) -> Self { cx.observe_window_appearance(window, |_, window, cx| { cx.update_global::(|global, cx| { global.current_theme = window.appearance().into(); cx.notify(); }); }) .detach(); Self {} } } impl gpui::Render for Chrome { fn render( &mut self, _window: &mut gpui::Window, cx: &mut gpui::Context, ) -> impl gpui::IntoElement { let title_bar = cx.new(|cx| titlebar::TitleBar::new(cx)); let dashboard = cx.new(|_| dashboard::Screen { text: "World".into(), }); div() .flex() .flex_col() .size_full() .child(title_bar) .child(dashboard) } } impl gpui::Global for Global {} pub fn current_theme<'a, E>(cx: &'a gpui::Context) -> &'a theme::Theme { &cx.global::().current_theme } pub fn query_store<'a, E>(cx: &'a gpui::Context) -> &'a query::Store { cx.global::>() }