Add channel name header to chat panel

This commit is contained in:
Max Brunsfeld
2021-08-26 17:12:56 -07:00
parent f810464983
commit 38d0258049
5 changed files with 33 additions and 2 deletions
+4
View File
@@ -237,6 +237,10 @@ impl Channel {
}
}
pub fn name(&self) -> &str {
&self.details.name
}
pub fn send_message(&mut self, body: String, cx: &mut ModelContext<Self>) -> Result<()> {
let channel_id = self.details.id;
let current_user_id = self.current_user_id()?;
+23
View File
@@ -99,6 +99,28 @@ impl ChatPanel {
cx.notify();
}
fn render_channel_name(&self, cx: &RenderContext<Self>) -> ElementBox {
let settings = self.settings.borrow();
let theme = &settings.theme.chat_panel;
if let Some((channel, _)) = self.active_channel.as_ref() {
let channel = channel.read(cx);
Flex::row()
.with_child(
Container::new(
Label::new("#".to_string(), theme.channel_name_hash.label.clone()).boxed(),
)
.with_style(&theme.channel_name_hash.container)
.boxed(),
)
.with_child(
Label::new(channel.name().to_string(), theme.channel_name.clone()).boxed(),
)
.boxed()
} else {
Empty::new().boxed()
}
}
fn render_active_channel_messages(&self, cx: &RenderContext<Self>) -> ElementBox {
let messages = if let Some((channel, _)) = self.active_channel.as_ref() {
let channel = channel.read(cx);
@@ -184,6 +206,7 @@ impl View for ChatPanel {
let theme = &self.settings.borrow().theme;
Container::new(
Flex::column()
.with_child(self.render_channel_name(cx))
.with_child(self.render_active_channel_messages(cx))
.with_child(self.render_input_box())
.boxed(),
+2
View File
@@ -62,6 +62,8 @@ pub struct ChatPanel {
#[serde(flatten)]
pub container: ContainerStyle,
pub message: ChatMessage,
pub channel_name: TextStyle,
pub channel_name_hash: ContainedLabel,
}
#[derive(Deserialize)]