diff --git a/crates/client/lang/en/chat.txt b/crates/client/lang/en/chat.txt index def63b9..1419192 100644 --- a/crates/client/lang/en/chat.txt +++ b/crates/client/lang/en/chat.txt @@ -29,7 +29,6 @@ unknown = unknown typing_one = {name} is typing… typing_many = {count} people are typing… new_messages = {count} new messages -people = People send = Send ghost_title = Speak as ghost? ghost_hint = Everyone in the call will hear you. diff --git a/crates/client/lang/tr/chat.txt b/crates/client/lang/tr/chat.txt index b1e3fe3..9fc6980 100644 --- a/crates/client/lang/tr/chat.txt +++ b/crates/client/lang/tr/chat.txt @@ -29,7 +29,6 @@ unknown = bilinmiyor typing_one = {name} yazıyor… typing_many = {count} kişi yazıyor… new_messages = {count} yeni mesaj -people = Kişiler send = Gönder ghost_title = Hayalet olarak konuş? ghost_hint = Aramadaki herkes seni duyacak. 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 3fa8148..089986e 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -271,7 +271,6 @@ pub struct Chat { pub(super) followed: Option<(Id, common::stats::Stats)>, pub(super) share_loss: HashMap<(Id, Kind), VecDeque>, pub(super) stats_at: Option, - pub(super) members_open: bool, pub(super) offline_open: bool, pub(super) usage_monitor: crate::usage::Monitor, pub(super) ringing: HashSet, @@ -558,7 +557,6 @@ impl Chat { followed: None, share_loss: HashMap::new(), stats_at: None, - members_open: true, offline_open: false, usage_monitor: { let monitor = crate::usage::Monitor::default(); @@ -1547,30 +1545,22 @@ impl Yumush { .child(title), ) .into_any_element(), - (None, Some(room)) => clickable( - "room_title", - palette, - entity_action(entity, |yumush, _, cx| { - yumush.chat.members_open = !yumush.chat.members_open; - cx.notify(); - }), - ) - .tip(w().chat.people) - .flex() - .items_center() - .gap(px(space::SM)) - .child(super::community_icon( - palette, + (None, Some(room)) => super::community_card::community_popover( room, - px(size::AVATAR), - super::text(super::style::text::CAPTION), - &self.chat.avatars, - )) - .child(title) - .child( - Icon::new(IconName::ChevronDown) - .size(px(size::ICON_SM)) - .text_color(palette.tokens.faint()), + 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() @@ -3001,7 +2991,7 @@ fn members_column( let group = chat .selected_community() .is_some_and(|community| matches!(community.kind, CommunityKind::Group)); - if !chat.members_open || !group { + if !group { return None; } let voice = chat.voice_ids(community_id); 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), + ) + })), + ) + }) +}