forge
Explore
Log in

Don't you dare go Hollow

Community card from the room header (icon zooms, members online, invite/settings/pin/mute/leave)

Browse files at this commit

e04c20bc4bc5515c5e8ddb76362ce1143a4f26cdAhmet Kaan GümüşParent: eccb83b
  • feat
    • community card from the room header (icon zooms, members online, invite/settings/pin/mute/leave)
    • pinned chats show a pin in the sidebar
Show full message
✨ feat: community card from the room header (icon zooms, members online, invite/settings/pin/mute/leave); pinned chats show a pin in the sidebar
crates/client/lang/en/community_card.txtadded+1 -0
@@ -0,0 +1 @@
1+people = {members} members · {online} online
crates/client/lang/tr/community_card.txtadded+1 -0
@@ -0,0 +1 @@
1+people = {members} üye · {online} çevrimiçi
crates/client/src/gui.rsmodified+1 -0
@@ -43,6 +43,7 @@ mod builder;
43 mod call_bar;43 mod call_bar;
44 mod camera_view;44 mod camera_view;
45 mod chat;45 mod chat;
46+mod community_card;
46 mod community_settings;47 mod community_settings;
47 mod composer;48 mod composer;
48 mod dock;49 mod dock;
crates/client/src/gui/chat.rsmodified+22 -3
@@ -1512,6 +1512,7 @@ impl Yumush {
1512 CommunityKind::Direct { peer } => Some(self.chat.author(peer.id).unwrap_or(peer)),1512 CommunityKind::Direct { peer } => Some(self.chat.author(peer.id).unwrap_or(peer)),
1513 _ => None,1513 _ => None,
1514 });1514 });
1515+ let room = community.filter(|_| group);
1515 let title = super::parts::words(1516 let title = super::parts::words(
1516 name.to_string(),1517 name.to_string(),
1517 super::parts::Text::Title,1518 super::parts::Text::Title,
@@ -1525,8 +1526,8 @@ impl Yumush {
1525 .flex()1526 .flex()
1526 .items_center()1527 .items_center()
1527 .gap(px(space::SM))1528 .gap(px(space::SM))
1528- .child(match peer {1529+ .child(match (peer, room) {
1529- Some(peer) => super::profile::profile_popover(1530+ (Some(peer), _) => super::profile::profile_popover(
1530 "header_peer",1531 "header_peer",
1531 Anchor::TopLeft,1532 Anchor::TopLeft,
1532 peer,1533 peer,
@@ -1546,7 +1547,25 @@ impl Yumush {
1546 .child(title),1547 .child(title),
1547 )1548 )
1548 .into_any_element(),1549 .into_any_element(),
1549- None => div()1550+ (None, Some(room)) => super::community_card::community_popover(
1551+ room,
1552+ entity,
1553+ div()
1554+ .cursor_pointer()
1555+ .flex()
1556+ .items_center()
1557+ .gap(px(space::SM))
1558+ .child(super::community_icon(
1559+ palette,
1560+ room,
1561+ px(size::AVATAR),
1562+ super::text(super::style::text::CAPTION),
1563+ &self.chat.avatars,
1564+ ))
1565+ .child(title),
1566+ )
1567+ .into_any_element(),
1568+ _ => div()
1550 .flex()1569 .flex()
1551 .items_center()1570 .items_center()
1552 .gap(px(space::SM))1571 .gap(px(space::SM))
crates/client/src/gui/community_card.rsadded+157 -0
@@ -0,0 +1,157 @@
1+use common::{
2+ model::{Community, Id, Presence},
3+ permission,
4+};
5+use gpui_kit::{
6+ Anchor, Context, Entity, FontWeight, Hsla, IntoElement, ParentElement, Styled, Window,
7+ assets::IconName, component::popover::Popover, div, px,
8+};
9+
10+use super::parts::{Ink, Text, band, stack, words};
11+use super::profile::{menu_icon, menu_row, yumush_action};
12+use super::style::{size, space, stroke, text};
13+use super::{Trigger, Yumush, text};
14+use crate::lang::w;
15+use crate::marks::Mark;
16+
17+pub(super) fn community_popover(
18+ community: &Community,
19+ entity: &Entity<Yumush>,
20+ trigger: impl IntoElement,
21+) -> Popover {
22+ let community = community.clone();
23+ let entity = entity.clone();
24+
25+ Popover::new("community_card")
26+ .anchor(Anchor::TopLeft)
27+ .appearance(false)
28+ .trigger(Trigger::new(trigger))
29+ .content(move |_, _, cx| {
30+ let popover = cx.entity();
31+ let yumush = entity.read(cx);
32+ let palette = super::palette(cx);
33+ let t = palette.tokens;
34+ let id = community.id;
35+ let name = super::community_name(&community).to_string();
36+ let members = yumush.chat.members.len();
37+ let online = yumush
38+ .chat
39+ .members
40+ .iter()
41+ .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline)
42+ .count();
43+ let pinned = yumush.chat.pinned.contains(&id);
44+ let muted = yumush.chat.muted.contains(&id);
45+ let can_leave = permission::can_leave(yumush.actor_rank());
46+ let words_sidebar = &w().sidebar;
47+ let row =
48+ |key: &'static str,
49+ label: &'static str,
50+ icon: IconName,
51+ color: Hsla,
52+ run: fn(&mut Yumush, Id, &mut Window, &mut Context<Yumush>)| {
53+ menu_row(
54+ key,
55+ label,
56+ menu_icon(icon),
57+ color,
58+ palette,
59+ yumush_action(&entity, &popover, move |yumush, window, cx| {
60+ run(yumush, id, window, cx)
61+ }),
62+ )
63+ };
64+
65+ super::parts::popover(t)
66+ .w(px(size::POPOVER))
67+ .gap(px(space::LG))
68+ .child(
69+ band(space::LG)
70+ .child(super::zoomable(
71+ &entity,
72+ "community_picture",
73+ super::community_icon(
74+ palette,
75+ &community,
76+ px(size::AVATAR_LG),
77+ text(text::BODY),
78+ &yumush.chat.avatars,
79+ ),
80+ super::Zoom::new(
81+ super::picture_of(&community, &yumush.chat.avatars),
82+ false,
83+ name.clone(),
84+ ),
85+ ))
86+ .child(
87+ stack(space::XXS)
88+ .flex_1()
89+ .min_w_0()
90+ .child(
91+ words(name, Text::Body, Ink::Paper, t)
92+ .font_weight(FontWeight::MEDIUM)
93+ .truncate(),
94+ )
95+ .child(words(
96+ w().community_card.people(members, online),
97+ Text::Caption,
98+ Ink::Dim,
99+ t,
100+ )),
101+ ),
102+ )
103+ .child(div().w_full().h(px(stroke::LINE)).bg(t.thread()))
104+ .child(
105+ stack(space::XS)
106+ .child(row(
107+ "community_invite",
108+ words_sidebar.invite,
109+ IconName::UserPlus,
110+ palette.text,
111+ |yumush, id, window, cx| yumush.open_invite(id, window, cx),
112+ ))
113+ .child(row(
114+ "community_settings",
115+ words_sidebar.settings,
116+ IconName::Settings,
117+ palette.text,
118+ |yumush, id, window, cx| yumush.open_community_settings(id, window, cx),
119+ ))
120+ .child(row(
121+ "community_pin",
122+ if pinned {
123+ words_sidebar.unpin
124+ } else {
125+ words_sidebar.pin
126+ },
127+ IconName::Pin,
128+ palette.text,
129+ |yumush, id, _, cx| yumush.toggle_mark(Mark::Pin, id, cx),
130+ ))
131+ .child(row(
132+ "community_mute",
133+ if muted {
134+ words_sidebar.unmute
135+ } else {
136+ words_sidebar.mute
137+ },
138+ if muted {
139+ IconName::Bell
140+ } else {
141+ IconName::BellOff
142+ },
143+ palette.text,
144+ |yumush, id, _, cx| yumush.toggle_mark(Mark::Mute, id, cx),
145+ ))
146+ .children(can_leave.then(|| {
147+ row(
148+ "community_leave",
149+ words_sidebar.leave,
150+ IconName::LogOut,
151+ palette.danger,
152+ |yumush, id, window, cx| yumush.leave_community(id, window, cx),
153+ )
154+ })),
155+ )
156+ })
157+}
crates/client/src/gui/profile.rsmodified+3 -3
@@ -748,7 +748,7 @@ fn card_menu_action(
748 })748 })
749 }749 }
750 750
751-fn yumush_action(751+pub(super) fn yumush_action(
752 entity: &Entity<Yumush>,752 entity: &Entity<Yumush>,
753 popover: &Entity<PopoverState>,753 popover: &Entity<PopoverState>,
754 run: impl Fn(&mut Yumush, &mut Window, &mut Context<Yumush>) + 'static,754 run: impl Fn(&mut Yumush, &mut Window, &mut Context<Yumush>) + 'static,
@@ -783,7 +783,7 @@ fn delete_user_action(
783 }783 }
784 }784 }
785 785
786-fn menu_icon(icon: IconName) -> Icon {786+pub(super) fn menu_icon(icon: IconName) -> Icon {
787 Icon::new(icon).size(px(size::ICON_SM))787 Icon::new(icon).size(px(size::ICON_SM))
788 }788 }
789 789
@@ -846,7 +846,7 @@ fn presence_menu(current: Presence, entity: &Entity<Yumush>, palette: Palette) -
846 })846 })
847 }847 }
848 848
849-fn menu_row(849+pub(super) fn menu_row(
850 id: impl Into<ElementId>,850 id: impl Into<ElementId>,
851 label: impl Into<SharedString>,851 label: impl Into<SharedString>,
852 leading: impl IntoElement,852 leading: impl IntoElement,
crates/client/src/gui/sidebar.rsmodified+9 -1
@@ -746,8 +746,16 @@ impl Yumush {
746 let community_id = community.id;746 let community_id = community.id;
747 let select = entity.clone();747 let select = entity.clone();
748 748
749+ let pinned = self.chat.pinned.contains(&community.id);
749 let trailing = if self.chat.voice_ids(community_id).is_empty() {750 let trailing = if self.chat.voice_ids(community_id).is_empty() {
750- unread_badge(palette, muted, unread)751+ unread_badge(palette, muted, unread).or_else(|| {
752+ pinned.then(|| {
753+ Icon::new(IconName::Pin)
754+ .size(px(size::ICON_SM))
755+ .text_color(palette.muted)
756+ .into_any_element()
757+ })
758+ })
751 } else {759 } else {
752 Some(self.voice_chip(entity, community_id, palette))760 Some(self.voice_chip(entity, community_id, palette))
753 };761 };