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