update dock
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use assets::CustomIconName;
|
||||
use dock::{DockArea, DockPlacement, Panel, PanelEvent, title_bar_drag_handlers};
|
||||
use gpui::prelude::*;
|
||||
use gpui::{
|
||||
App, ClickEvent, Context, ElementId, EventEmitter, FocusHandle, Focusable, Render,
|
||||
SharedString, StyleRefinement, Subscription, WeakEntity, Window, div,
|
||||
SharedString, StyleRefinement, Subscription, WeakEntity, Window, div, px,
|
||||
};
|
||||
use gpui_component::avatar::Avatar;
|
||||
use gpui_component::button::{Button, ButtonVariants};
|
||||
use dock::{DockArea, DockPlacement, Panel, PanelEvent};
|
||||
use gpui_component::input::InputState;
|
||||
use gpui_component::{ActiveTheme, Icon, IconName, Sizable, StyledExt, h_flex, v_flex};
|
||||
use signed_state::{Backend, BackendEvent, ProfileStore};
|
||||
@@ -129,7 +129,7 @@ impl Focusable for SidebarPanel {
|
||||
}
|
||||
|
||||
impl Render for SidebarPanel {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
if !self.logged_in {
|
||||
return v_flex()
|
||||
.p_4()
|
||||
@@ -183,11 +183,16 @@ impl Render for SidebarPanel {
|
||||
let name = profile.name();
|
||||
let picture = profile.picture();
|
||||
|
||||
this.child(
|
||||
this.child(title_bar_drag_handlers(
|
||||
h_flex()
|
||||
.id("sidebar-profile")
|
||||
.h_12()
|
||||
.px_3()
|
||||
.gap_2()
|
||||
// The macOS traffic lights overlay the
|
||||
// top-left corner of the window; keep the
|
||||
// profile content clear of them.
|
||||
.when(cfg!(target_os = "macos"), |this| this.pl(px(80.)))
|
||||
.child(
|
||||
Avatar::new()
|
||||
.name(name.clone())
|
||||
@@ -196,7 +201,9 @@ impl Render for SidebarPanel {
|
||||
.border_0(),
|
||||
)
|
||||
.child(div().text_sm().child(name)),
|
||||
)
|
||||
window,
|
||||
cx,
|
||||
))
|
||||
})
|
||||
.child(
|
||||
v_flex()
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use assets::CustomIconName;
|
||||
use dock::{DockArea, DockItem};
|
||||
use gpui::prelude::*;
|
||||
use gpui::{Context, Entity, Render, SharedString, Subscription, Window, div, px};
|
||||
use gpui_component::button::{Button, ButtonVariants};
|
||||
use gpui_component::{ActiveTheme, Root, Sizable, StyledExt, Theme, TitleBar, h_flex, v_flex};
|
||||
use gpui::{Context, Entity, Render, Subscription, Window, div, px};
|
||||
use gpui_component::{Root, StyledExt, Theme};
|
||||
use signed_state::{Backend, BackendEvent};
|
||||
|
||||
use crate::views::SidebarPanel;
|
||||
use crate::views::sidebar::passphrase_dialog;
|
||||
|
||||
/// Root view of the app: title bar, dock area, status bar.
|
||||
/// Root view of the app: dock area (whose center tab bar doubles as the
|
||||
/// window title bar), overlays.
|
||||
pub struct Workspace {
|
||||
dock: Entity<DockArea>,
|
||||
status: SharedString,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
_passphrase_subscription: Subscription,
|
||||
}
|
||||
@@ -40,16 +38,6 @@ impl Workspace {
|
||||
});
|
||||
|
||||
let backend = Backend::global(cx);
|
||||
let connected = backend.read(cx).is_connected();
|
||||
let sync_progress = backend.read(cx).sync_progress();
|
||||
|
||||
let status = if let Some((total, current)) = sync_progress {
|
||||
format!("Syncing repositories... {current}/{total}").into()
|
||||
} else if connected {
|
||||
"Connected".into()
|
||||
} else {
|
||||
"Connecting...".into()
|
||||
};
|
||||
|
||||
let mut subscriptions = vec![];
|
||||
|
||||
@@ -57,19 +45,6 @@ impl Workspace {
|
||||
Theme::sync_system_appearance(Some(window), cx);
|
||||
}));
|
||||
|
||||
subscriptions.push(cx.subscribe(&backend, |this, _backend, event, cx| {
|
||||
match event {
|
||||
BackendEvent::SyncProgress { total, current } => {
|
||||
this.status = format!("Syncing repositories... {current}/{total}").into()
|
||||
}
|
||||
BackendEvent::Synced => this.status = "Connected".into(),
|
||||
BackendEvent::Connected => this.status = "Connected".into(),
|
||||
BackendEvent::Error(error) => this.status = error.clone().into(),
|
||||
_ => return,
|
||||
}
|
||||
cx.notify();
|
||||
}));
|
||||
|
||||
// Ask for the passphrase when the stored identity is NIP-49
|
||||
// encrypted. Subscribed via the window, since opening a dialog
|
||||
// needs one.
|
||||
@@ -98,7 +73,6 @@ impl Workspace {
|
||||
|
||||
Self {
|
||||
dock,
|
||||
status,
|
||||
_subscriptions: subscriptions,
|
||||
_passphrase_subscription: passphrase_subscription,
|
||||
}
|
||||
@@ -111,44 +85,11 @@ impl Render for Workspace {
|
||||
let notification_layer = Root::render_notification_layer(window, cx);
|
||||
|
||||
div()
|
||||
// All `img` elements below (avatars, …) load through the shared
|
||||
// bounded LRU cache instead of the window-global asset cache,
|
||||
// so images can be freed when views close or when the cache is
|
||||
// full.
|
||||
.image_cache(crate::image_cache::global(cx))
|
||||
.id("workspace")
|
||||
.v_flex()
|
||||
.size_full()
|
||||
.child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
// Title Bar
|
||||
.child(
|
||||
TitleBar::new()
|
||||
// Left
|
||||
.child(div())
|
||||
// Right
|
||||
.child(h_flex().px_2().map(|this| {
|
||||
if self.status == "Connected" {
|
||||
this.child(
|
||||
Button::new("relay")
|
||||
.icon(CustomIconName::GlobalOn)
|
||||
.small()
|
||||
.ghost(),
|
||||
)
|
||||
} else {
|
||||
this.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(self.status.clone()),
|
||||
)
|
||||
}
|
||||
})),
|
||||
)
|
||||
// Dock Area
|
||||
.child(self.dock.clone()),
|
||||
)
|
||||
.child(self.dock.clone())
|
||||
// Notifications
|
||||
.children(notification_layer)
|
||||
// Modals
|
||||
|
||||
Reference in New Issue
Block a user