wip: refactor

This commit is contained in:
reya
2024-12-25 13:44:16 +07:00
parent 37d810d9e5
commit 0745b497f0
13 changed files with 117 additions and 120 deletions
+6 -7
View File
@@ -1,6 +1,6 @@
use coop_ui::{
button::Button,
dock::{Panel, PanelEvent, PanelState, TitleStyle},
dock::{Panel, PanelEvent, PanelState},
popup_menu::PopupMenu,
};
use gpui::*;
@@ -18,11 +18,13 @@ pub struct ChatPanel {
zoomable: bool,
focus_handle: FocusHandle,
// Room
id: SharedString,
room: View<ChatRoom>,
}
impl ChatPanel {
pub fn new(room: &Arc<Room>, cx: &mut WindowContext) -> View<Self> {
let id = room.id.clone();
let room = cx.new_view(|cx| {
let view = ChatRoom::new(room, cx);
// Load messages
@@ -38,24 +40,21 @@ impl ChatPanel {
closeable: true,
zoomable: true,
focus_handle: cx.focus_handle(),
id,
room,
})
}
}
impl Panel for ChatPanel {
fn panel_name(&self) -> &'static str {
"ChatPanel"
fn panel_name(&self) -> SharedString {
self.id.clone()
}
fn title(&self, _cx: &WindowContext) -> AnyElement {
self.name.clone().into_any_element()
}
fn title_style(&self, _cx: &WindowContext) -> Option<TitleStyle> {
None
}
fn closeable(&self, _cx: &WindowContext) -> bool {
self.closeable
}