Redesign for the v1 stable release #3

Merged
reya merged 30 commits from v1-redesign into master 2026-02-04 01:43:24 +00:00
2 changed files with 26 additions and 15 deletions
Showing only changes of commit 311af51bee - Show all commits

View File

@@ -12,12 +12,12 @@ use ui::Root;
use crate::actions::Quit;
mod actions;
mod chatspace;
mod login;
mod new_identity;
mod sidebar;
mod user;
mod views;
mod workspace;
fn main() {
// Initialize logging
@@ -111,7 +111,7 @@ fn main() {
auto_update::init(cx);
// Root Entity
Root::new(chatspace::init(window, cx).into(), window, cx)
Root::new(workspace::init(window, cx).into(), window, cx)
})
})
.expect("Failed to open window. Please restart the application.");

View File

@@ -31,30 +31,30 @@ use crate::actions::{
use crate::user::viewer;
use crate::views::compose::compose_button;
use crate::views::{preferences, setup_relay, welcome};
use crate::{login, sidebar, user};
use crate::{sidebar, user};
pub fn init(window: &mut Window, cx: &mut App) -> Entity<ChatSpace> {
cx.new(|cx| ChatSpace::new(window, cx))
pub fn init(window: &mut Window, cx: &mut App) -> Entity<Workspace> {
cx.new(|cx| Workspace::new(window, cx))
}
#[derive(Debug)]
pub struct ChatSpace {
pub struct Workspace {
/// App's Title Bar
title_bar: Entity<TitleBar>,
/// App's Dock Area
dock: Entity<DockArea>,
/// Determines if the chat space is ready to use
ready: bool,
/// Event subscriptions
_subscriptions: SmallVec<[Subscription; 3]>,
_subscriptions: SmallVec<[Subscription; 4]>,
}
impl ChatSpace {
impl Workspace {
fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let chat = ChatRegistry::global(cx);
let nostr = NostrRegistry::global(cx);
let identity = nostr.read(cx).identity();
let title_bar = cx.new(|_| TitleBar::new());
let dock = cx.new(|cx| DockArea::new(window, cx));
@@ -67,6 +67,17 @@ impl ChatSpace {
}),
);
subscriptions.push(
// Observe the identity entity
cx.observe_in(&identity, window, move |this, state, window, cx| {
if state.read(cx).has_public_key() {
this.dock.update(cx, |this, cx| {
this.toggle_dock(DockPlacement::Left, window, cx);
});
};
}),
);
subscriptions.push(
// Observe all events emitted by the chat registry
cx.subscribe_in(&chat, window, move |this, chat, ev, window, cx| {
@@ -87,6 +98,7 @@ impl ChatSpace {
this.dock.update(cx, |this, cx| {
// Force focus to the tab panel
this.focus_tab_panel(window, cx);
// Dispatch the close panel action
cx.defer_in(window, |_, window, cx| {
window.dispatch_action(Box::new(ClosePanel), cx);
@@ -118,7 +130,6 @@ impl ChatSpace {
Self {
dock,
title_bar,
ready: false,
_subscriptions: subscriptions,
}
}
@@ -147,7 +158,7 @@ impl ChatSpace {
// Update the dock layout
self.dock.update(cx, |this, cx| {
this.set_left_dock(left, Some(px(DEFAULT_SIDEBAR_WIDTH)), true, window, cx);
this.set_left_dock(left, Some(px(DEFAULT_SIDEBAR_WIDTH)), false, window, cx);
this.set_center(center, window, cx);
});
}
@@ -483,7 +494,7 @@ impl ChatSpace {
}
}
impl Render for ChatSpace {
impl Render for Workspace {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let modal_layer = Root::render_modal_layer(window, cx);
let notification_layer = Root::render_notification_layer(window, cx);
@@ -496,7 +507,7 @@ impl Render for ChatSpace {
});
div()
.id(SharedString::from("chatspace"))
.id(SharedString::from("workspace"))
.on_action(cx.listener(Self::on_settings))
.on_action(cx.listener(Self::on_profile))
.on_action(cx.listener(Self::on_relays))