rewrite app root
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run

This commit is contained in:
2026-11-17 10:01:42 +07:00
parent d1a4cfe9fb
commit 0cd0e4672f
+35 -34
View File
@@ -2,6 +2,9 @@ pub mod helpers;
mod placeholder;
mod sign_in;
use std::sync::Arc;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render, Styled as _,
Subscription, Window, div,
@@ -90,50 +93,48 @@ impl AppRoot {
impl Render for AppRoot {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let is_signed_in = Backend::global(cx).read(cx).current_user().is_some();
let backend = Backend::global(cx);
let signed_in = backend.read(cx).current_user().is_some();
let titlebar_view = self.titlebar.read(cx);
let mut titlebar = Titlebar::new("signed-titlebar");
if let Some(actions) = titlebar_view.render_actions(cx) {
titlebar = titlebar.child(actions);
}
if let Some(tabs) = titlebar_view.render_tabs(cx) {
titlebar = titlebar.tab_bar(tabs);
}
if let Some(menu) = titlebar_view.render_user_menu(cx) {
titlebar = titlebar.suffix(menu);
}
let workspace = self.workspace.read(cx);
let mut row = PanelRow::new("signed-panel");
if is_signed_in {
match workspace.active_main() {
Some(main) => row = row.main(main),
None => row = row.main(self.empty.clone()),
}
if workspace.has_details() {
row = row.split(self.workspace.clone());
}
} else {
row = row.main(self.sign_in.clone());
}
let mut root = div()
div()
.relative()
.size_full()
.font_family(".SystemUIFont")
.text_color(cx.theme().colors.foreground)
.child(
Shell::new("signed-shell")
.titlebar(titlebar)
.panel(row)
.transparent(true)
.titlebar(
Titlebar::new("signed-titlebar")
.when_some(titlebar_view.render_actions(cx), |titlebar, actions| {
titlebar.child(actions)
})
.when_some(titlebar_view.render_tabs(cx), |titlebar, tabs| {
titlebar.tab_bar(tabs)
})
.when_some(titlebar_view.render_user_menu(cx), |titlebar, menu| {
titlebar.suffix(menu)
}),
)
.panel(
PanelRow::new("signed-panel")
.when(signed_in, |row| {
row.main(
workspace
.active_main()
.unwrap_or_else(|| Arc::new(self.empty.clone())),
)
.when(workspace.has_details(), |row| {
row.split(self.workspace.clone())
})
})
.when(!signed_in, |row| row.main(self.sign_in.clone())),
)
.toasts(self.toasts.clone()),
)
.child(self.dialogs.clone());
if is_signed_in {
root = root.child(titlebar_view.palette());
}
root
.child(self.dialogs.clone())
.when(signed_in, |root| root.child(titlebar_view.palette()))
}
}