Messaging · Channels: the chat list, its rows, a channel's head and its pins

ChannelList sets chats down in sections, each a list: a press, an arrow
or Enter opens one, and the open chat is lit. A title names one section,
and a section holds a chat. ChannelItem shows a hash or a lock, its
unread count, a pin when pinned, and goes quiet when muted.
DirectMessageItem shows a person's initials with their presence. Unread
names stand out through ListItem's new strong; muted channels and
offline people go quiet through its quiet. ChannelHeader holds the name
and topic beside members, pins and a call, wrapping by the header rule.
PinnedMessages lists pins newest first; a press, an arrow or Enter opens
one, and Unpin lets one go. With none it shows a line and takes no Tab
stop.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 21:30:17 -04:00
1 parent 85df47fd5c
commit cd14b32dfe
11 files changed
+1188 -17

No files matched your search

+25 -4
View File
@@ -1,9 +1,9 @@
use std::rc::Rc;
use gpui::{
AnyElement, App, ClickEvent, ElementId, InteractiveElement, IntoElement, MouseButton,
ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, Styled, Window, div,
prelude::*, relative,
AnyElement, App, ClickEvent, ElementId, FontWeight, InteractiveElement, IntoElement,
MouseButton, ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, Styled,
Window, div, prelude::*, relative,
};
use smallvec::SmallVec;
@@ -25,6 +25,8 @@ pub struct ListItem {
selected: bool,
current: bool,
disabled: bool,
strong: bool,
quiet: bool,
on_click: Option<OnClick>,
}
@@ -39,10 +41,24 @@ impl ListItem {
selected: false,
current: false,
disabled: false,
strong: false,
quiet: false,
on_click: None,
}
}
/// Sets the title in the strong weight, as a channel with unread messages has it.
pub fn strong(mut self, strong: bool) -> Self {
self.strong = strong;
self
}
/// Sets the title in the quiet color, as a muted channel has it.
pub fn quiet(mut self, quiet: bool) -> Self {
self.quiet = quiet;
self
}
/// A second line, quieter than the title.
pub fn description(mut self, text: impl Into<SharedString>) -> Self {
self.description = Some(text.into());
@@ -137,7 +153,12 @@ impl RenderOnce for ListItem {
.child(
line(self.title)
.text_size(theme.text_size(TextSize::Base))
.text_color(colors.fg),
.when(self.strong, |title| title.font_weight(FontWeight::SEMIBOLD))
.text_color(if self.quiet {
colors.fg_muted
} else {
colors.fg
}),
)
.children(self.description.map(|text| {
line(text)