refactor: replace shell with root view wrapping app content
This commit is contained in:
@@ -10,13 +10,12 @@ use gpui::{
|
||||
use helpers::apply_appearance_mode;
|
||||
use settings::SettingsStore;
|
||||
use signed_state::{Backend, BackendEvent};
|
||||
use ui::common::h_flex;
|
||||
use ui::common::{h_flex, v_flex};
|
||||
use ui::icons::IconRole;
|
||||
use ui::layout::panel::PanelRow;
|
||||
use ui::layout::shell::Shell;
|
||||
use ui::layout::root::Root;
|
||||
use ui::layout::titlebar::Titlebar;
|
||||
use ui::theme::ActiveTheme as _;
|
||||
use ui::toast::{Toast, Toasts};
|
||||
use ui::toast::Toast;
|
||||
|
||||
use crate::app::placeholder::PlaceholderView;
|
||||
use crate::app::sign_in::SignedOutView;
|
||||
@@ -32,7 +31,6 @@ use crate::workspace::Workspace;
|
||||
pub struct AppRoot {
|
||||
workspace: Entity<Workspace>,
|
||||
titlebar: Entity<TitlebarView>,
|
||||
toasts: Entity<Toasts>,
|
||||
sign_in: Entity<SignedOutView>,
|
||||
explore: Entity<ExploreView>,
|
||||
empty: Entity<PlaceholderView>,
|
||||
@@ -47,7 +45,6 @@ impl AppRoot {
|
||||
let workspace = cx.new(|_| Workspace::new());
|
||||
let titlebar = cx.new(|cx| TitlebarView::new(workspace.downgrade(), window, cx));
|
||||
|
||||
let toasts = cx.new(|_| Toasts::default());
|
||||
let sign_in = cx.new(|_| SignedOutView::new());
|
||||
let explore = cx.new(|cx| ExploreView::new(workspace.downgrade(), cx));
|
||||
let empty = cx.new(|_| PlaceholderView::new("Select a repository"));
|
||||
@@ -64,9 +61,7 @@ impl AppRoot {
|
||||
this.open_passphrase(cx);
|
||||
}
|
||||
BackendEvent::Error(message) => {
|
||||
this.toasts.update(cx, |toasts, cx| {
|
||||
toasts.push(Toast::new(message.clone()).icon(IconRole::Warning), cx);
|
||||
});
|
||||
Root::push_toast(Toast::new(message.clone()).icon(IconRole::Warning), cx);
|
||||
}
|
||||
BackendEvent::SignerChanged => {
|
||||
this.workspace.update(cx, |workspace, cx| {
|
||||
@@ -95,7 +90,6 @@ impl AppRoot {
|
||||
Self {
|
||||
workspace,
|
||||
titlebar,
|
||||
toasts,
|
||||
sign_in,
|
||||
explore,
|
||||
empty,
|
||||
@@ -105,8 +99,12 @@ impl AppRoot {
|
||||
}
|
||||
|
||||
fn open_passphrase(&mut self, cx: &mut Context<Self>) {
|
||||
self.passphrase = Some(PassphraseDialog::new(cx));
|
||||
cx.notify();
|
||||
if self.passphrase.is_some() {
|
||||
return;
|
||||
}
|
||||
let dialog = PassphraseDialog::new(cx);
|
||||
self.passphrase = Some(dialog.clone());
|
||||
Root::open_dialog(dialog, cx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +120,6 @@ impl Render for AppRoot {
|
||||
div()
|
||||
.relative()
|
||||
.size_full()
|
||||
.font_family(cx.theme().ui_font())
|
||||
.text_color(cx.theme().colors.foreground)
|
||||
.key_context(REPOSITORY_KEY_CONTEXT)
|
||||
.on_action(cx.listener(|this, action: &SwitchRepository, window, cx| {
|
||||
this.titlebar.update(cx, |titlebar, cx| {
|
||||
@@ -136,8 +132,10 @@ impl Render for AppRoot {
|
||||
});
|
||||
}))
|
||||
.child(
|
||||
Shell::new("signed-shell")
|
||||
.titlebar(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.overflow_hidden()
|
||||
.child(
|
||||
Titlebar::new("signed-titlebar")
|
||||
.prefix(
|
||||
h_flex()
|
||||
@@ -154,7 +152,7 @@ impl Render for AppRoot {
|
||||
titlebar.suffix(menu)
|
||||
}),
|
||||
)
|
||||
.panel(
|
||||
.child(
|
||||
PanelRow::new("signed-panel")
|
||||
.when_some(main.as_ref(), |row, main| {
|
||||
row.main(main.clone()).when(workspace.has_details(), |row| {
|
||||
@@ -168,11 +166,7 @@ impl Render for AppRoot {
|
||||
row.main(self.sign_in.clone())
|
||||
.split_at(self.explore.clone(), px(300.))
|
||||
}),
|
||||
)
|
||||
.toasts(self.toasts.clone()),
|
||||
),
|
||||
)
|
||||
.child(titlebar_view.palette())
|
||||
.children(titlebar_view.dialogs())
|
||||
.when_some(self.passphrase.clone(), |el, view| el.child(view))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user