diff --git a/assets/icons/minimize.svg b/assets/icons/minimize.svg new file mode 100644 index 0000000..825fc19 --- /dev/null +++ b/assets/icons/minimize.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/app/src/views/app.rs b/crates/app/src/views/app.rs index 1b9c92f..83d3cec 100644 --- a/crates/app/src/views/app.rs +++ b/crates/app/src/views/app.rs @@ -3,14 +3,13 @@ use components::{ theme::{ActiveTheme, Theme}, Root, TitleBar, }; -use coop_ui::block::BlockContainer; use gpui::*; use nostr_sdk::prelude::*; use serde::Deserialize; use std::sync::Arc; use super::{ - dock::{left_dock::LeftDock, welcome::WelcomeBlock}, + dock::{chat::ChatPanel, left_dock::LeftDock, welcome::WelcomePanel}, onboarding::Onboarding, }; use crate::states::account::AccountState; @@ -66,7 +65,7 @@ impl AppView { } fn init_layout(dock_area: WeakView, cx: &mut WindowContext) { - let left = DockItem::panel(Arc::new(BlockContainer::panel::(cx))); + let left = DockItem::panel(Arc::new(LeftDock::new(cx))); let center = Self::init_dock_items(&dock_area, cx); _ = dock_area.update(cx, |view, cx| { @@ -90,7 +89,7 @@ impl AppView { Axis::Vertical, vec![DockItem::tabs( vec![ - Arc::new(BlockContainer::panel::(cx)), + Arc::new(WelcomePanel::new(cx)), // TODO: add chat block ], None, @@ -103,12 +102,11 @@ impl AppView { ) } - fn on_action_add_panel(&mut self, _action: &AddPanel, cx: &mut ViewContext) { - // TODO: add chat panel - let panel = Arc::new(BlockContainer::panel::(cx)); + fn on_action_add_panel(&mut self, action: &AddPanel, cx: &mut ViewContext) { + let chat_panel = Arc::new(ChatPanel::new(action.receiver, cx)); self.dock.update(cx, |dock_area, cx| { - dock_area.add_panel(panel, DockPlacement::Center, cx); + dock_area.add_panel(chat_panel, DockPlacement::Center, cx); }); } } diff --git a/crates/app/src/views/dock/chat.rs b/crates/app/src/views/dock/chat.rs deleted file mode 100644 index 131cd7c..0000000 --- a/crates/app/src/views/dock/chat.rs +++ /dev/null @@ -1,49 +0,0 @@ -use coop_ui::block::Block; -use gpui::*; - -pub struct ChatBlock { - focus_handle: FocusHandle, -} - -impl ChatBlock { - pub fn view(cx: &mut WindowContext) -> View { - cx.new_view(Self::new) - } - - fn new(cx: &mut ViewContext) -> Self { - Self { - focus_handle: cx.focus_handle(), - } - } -} - -impl Block for ChatBlock { - fn title() -> &'static str { - "Chat" - } - - fn new_view(cx: &mut WindowContext) -> View { - Self::view(cx) - } - - fn zoomable() -> bool { - false - } -} - -impl FocusableView for ChatBlock { - fn focus_handle(&self, _: &gpui::AppContext) -> gpui::FocusHandle { - self.focus_handle.clone() - } -} - -impl Render for ChatBlock { - fn render(&mut self, _cx: &mut gpui::ViewContext) -> impl IntoElement { - div() - .size_full() - .flex() - .items_center() - .justify_center() - .child("Test") - } -} diff --git a/crates/app/src/views/dock/chat/mod.rs b/crates/app/src/views/dock/chat/mod.rs new file mode 100644 index 0000000..4162f59 --- /dev/null +++ b/crates/app/src/views/dock/chat/mod.rs @@ -0,0 +1,87 @@ +use components::{ + button::Button, + dock::{DockItemState, Panel, PanelEvent, TitleStyle}, + popup_menu::PopupMenu, + theme::{ActiveTheme, Colorize}, + StyledExt, +}; +use gpui::*; +use nostr_sdk::*; + +pub struct ChatPanel { + // Panel + name: SharedString, + closeable: bool, + zoomable: bool, + focus_handle: FocusHandle, + // Chat Room + receiver: PublicKey, +} + +impl ChatPanel { + pub fn new(receiver: PublicKey, cx: &mut WindowContext) -> View { + cx.new_view(|cx| Self { + name: "Chat".into(), + closeable: true, + zoomable: true, + focus_handle: cx.focus_handle(), + receiver, + }) + } +} + +impl Panel for ChatPanel { + fn panel_name(&self) -> &'static str { + "ChatPanel" + } + + fn title(&self, _cx: &WindowContext) -> AnyElement { + self.name.clone().into_any_element() + } + + fn title_style(&self, _cx: &WindowContext) -> Option { + None + } + + fn closeable(&self, _cx: &WindowContext) -> bool { + self.closeable + } + + fn zoomable(&self, _cx: &WindowContext) -> bool { + self.zoomable + } + + fn popup_menu(&self, menu: PopupMenu, _cx: &WindowContext) -> PopupMenu { + menu.track_focus(&self.focus_handle) + } + + fn toolbar_buttons(&self, _cx: &WindowContext) -> Vec