From e04c20bc4bc5515c5e8ddb76362ce1143a4f26cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 28 Nov 2026 19:18:53 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20community=20card=20from=20t?= =?UTF-8?q?he=20room=20header=20(icon=20zooms,=20members=20online,=20invit?= =?UTF-8?q?e/settings/pin/mute/leave);=20pinned=20chats=20show=20a=20pin?= =?UTF-8?q?=20in=20the=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/lang/en/community_card.txt | 1 + crates/client/lang/tr/community_card.txt | 1 + crates/client/src/gui.rs | 1 + crates/client/src/gui/chat.rs | 25 +++- crates/client/src/gui/community_card.rs | 157 +++++++++++++++++++++++ crates/client/src/gui/profile.rs | 6 +- crates/client/src/gui/sidebar.rs | 10 +- 7 files changed, 194 insertions(+), 7 deletions(-) create mode 100644 crates/client/lang/en/community_card.txt create mode 100644 crates/client/lang/tr/community_card.txt create mode 100644 crates/client/src/gui/community_card.rs diff --git a/crates/client/lang/en/community_card.txt b/crates/client/lang/en/community_card.txt new file mode 100644 index 0000000..f8eefc4 --- /dev/null +++ b/crates/client/lang/en/community_card.txt @@ -0,0 +1 @@ +people = {members} members · {online} online diff --git a/crates/client/lang/tr/community_card.txt b/crates/client/lang/tr/community_card.txt new file mode 100644 index 0000000..89f04a4 --- /dev/null +++ b/crates/client/lang/tr/community_card.txt @@ -0,0 +1 @@ +people = {members} üye · {online} çevrimiçi diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index 034f74b..3f86dc5 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -43,6 +43,7 @@ mod builder; mod call_bar; mod camera_view; mod chat; +mod community_card; mod community_settings; mod composer; mod dock; diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 50b2316..27a591a 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -1512,6 +1512,7 @@ impl Yumush { CommunityKind::Direct { peer } => Some(self.chat.author(peer.id).unwrap_or(peer)), _ => None, }); + let room = community.filter(|_| group); let title = super::parts::words( name.to_string(), super::parts::Text::Title, @@ -1525,8 +1526,8 @@ impl Yumush { .flex() .items_center() .gap(px(space::SM)) - .child(match peer { - Some(peer) => super::profile::profile_popover( + .child(match (peer, room) { + (Some(peer), _) => super::profile::profile_popover( "header_peer", Anchor::TopLeft, peer, @@ -1546,7 +1547,25 @@ impl Yumush { .child(title), ) .into_any_element(), - None => div() + (None, Some(room)) => super::community_card::community_popover( + room, + entity, + div() + .cursor_pointer() + .flex() + .items_center() + .gap(px(space::SM)) + .child(super::community_icon( + palette, + room, + px(size::AVATAR), + super::text(super::style::text::CAPTION), + &self.chat.avatars, + )) + .child(title), + ) + .into_any_element(), + _ => div() .flex() .items_center() .gap(px(space::SM)) diff --git a/crates/client/src/gui/community_card.rs b/crates/client/src/gui/community_card.rs new file mode 100644 index 0000000..6e2e32b --- /dev/null +++ b/crates/client/src/gui/community_card.rs @@ -0,0 +1,157 @@ +use common::{ + model::{Community, Id, Presence}, + permission, +}; +use gpui_kit::{ + Anchor, Context, Entity, FontWeight, Hsla, IntoElement, ParentElement, Styled, Window, + assets::IconName, component::popover::Popover, div, px, +}; + +use super::parts::{Ink, Text, band, stack, words}; +use super::profile::{menu_icon, menu_row, yumush_action}; +use super::style::{size, space, stroke, text}; +use super::{Trigger, Yumush, text}; +use crate::lang::w; +use crate::marks::Mark; + +pub(super) fn community_popover( + community: &Community, + entity: &Entity, + trigger: impl IntoElement, +) -> Popover { + let community = community.clone(); + let entity = entity.clone(); + + Popover::new("community_card") + .anchor(Anchor::TopLeft) + .appearance(false) + .trigger(Trigger::new(trigger)) + .content(move |_, _, cx| { + let popover = cx.entity(); + let yumush = entity.read(cx); + let palette = super::palette(cx); + let t = palette.tokens; + let id = community.id; + let name = super::community_name(&community).to_string(); + let members = yumush.chat.members.len(); + let online = yumush + .chat + .members + .iter() + .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline) + .count(); + let pinned = yumush.chat.pinned.contains(&id); + let muted = yumush.chat.muted.contains(&id); + let can_leave = permission::can_leave(yumush.actor_rank()); + let words_sidebar = &w().sidebar; + let row = + |key: &'static str, + label: &'static str, + icon: IconName, + color: Hsla, + run: fn(&mut Yumush, Id, &mut Window, &mut Context)| { + menu_row( + key, + label, + menu_icon(icon), + color, + palette, + yumush_action(&entity, &popover, move |yumush, window, cx| { + run(yumush, id, window, cx) + }), + ) + }; + + super::parts::popover(t) + .w(px(size::POPOVER)) + .gap(px(space::LG)) + .child( + band(space::LG) + .child(super::zoomable( + &entity, + "community_picture", + super::community_icon( + palette, + &community, + px(size::AVATAR_LG), + text(text::BODY), + &yumush.chat.avatars, + ), + super::Zoom::new( + super::picture_of(&community, &yumush.chat.avatars), + false, + name.clone(), + ), + )) + .child( + stack(space::XXS) + .flex_1() + .min_w_0() + .child( + words(name, Text::Body, Ink::Paper, t) + .font_weight(FontWeight::MEDIUM) + .truncate(), + ) + .child(words( + w().community_card.people(members, online), + Text::Caption, + Ink::Dim, + t, + )), + ), + ) + .child(div().w_full().h(px(stroke::LINE)).bg(t.thread())) + .child( + stack(space::XS) + .child(row( + "community_invite", + words_sidebar.invite, + IconName::UserPlus, + palette.text, + |yumush, id, window, cx| yumush.open_invite(id, window, cx), + )) + .child(row( + "community_settings", + words_sidebar.settings, + IconName::Settings, + palette.text, + |yumush, id, window, cx| yumush.open_community_settings(id, window, cx), + )) + .child(row( + "community_pin", + if pinned { + words_sidebar.unpin + } else { + words_sidebar.pin + }, + IconName::Pin, + palette.text, + |yumush, id, _, cx| yumush.toggle_mark(Mark::Pin, id, cx), + )) + .child(row( + "community_mute", + if muted { + words_sidebar.unmute + } else { + words_sidebar.mute + }, + if muted { + IconName::Bell + } else { + IconName::BellOff + }, + palette.text, + |yumush, id, _, cx| yumush.toggle_mark(Mark::Mute, id, cx), + )) + .children(can_leave.then(|| { + row( + "community_leave", + words_sidebar.leave, + IconName::LogOut, + palette.danger, + |yumush, id, window, cx| yumush.leave_community(id, window, cx), + ) + })), + ) + }) +} diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index 4c721bc..da56f60 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -748,7 +748,7 @@ fn card_menu_action( }) } -fn yumush_action( +pub(super) fn yumush_action( entity: &Entity, popover: &Entity, run: impl Fn(&mut Yumush, &mut Window, &mut Context) + 'static, @@ -783,7 +783,7 @@ fn delete_user_action( } } -fn menu_icon(icon: IconName) -> Icon { +pub(super) fn menu_icon(icon: IconName) -> Icon { Icon::new(icon).size(px(size::ICON_SM)) } @@ -846,7 +846,7 @@ fn presence_menu(current: Presence, entity: &Entity, palette: Palette) - }) } -fn menu_row( +pub(super) fn menu_row( id: impl Into, label: impl Into, leading: impl IntoElement, diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index a7f9dc7..f79c95e 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -746,8 +746,16 @@ impl Yumush { let community_id = community.id; let select = entity.clone(); + let pinned = self.chat.pinned.contains(&community.id); let trailing = if self.chat.voice_ids(community_id).is_empty() { - unread_badge(palette, muted, unread) + unread_badge(palette, muted, unread).or_else(|| { + pinned.then(|| { + Icon::new(IconName::Pin) + .size(px(size::ICON_SM)) + .text_color(palette.muted) + .into_any_element() + }) + }) } else { Some(self.voice_chip(entity, community_id, palette)) };