Room margin is always open
Browse files at this commit3e7fee6941895fe0ac6f1ab7b97f0b4f1d2948efParent: 5aab7f6- style
- room margin is always open
- the room title opens the community card again
5 changed files +174 -28
- crates/client/lang/en/chat.txt +0 -1
- crates/client/lang/tr/chat.txt +0 -1
- crates/client/src/gui.rs +1 -0
- crates/client/src/gui/chat.rs +16 -26
- crates/client/src/gui/community_card.rs +157 -0
crates/client/lang/en/chat.txtmodified+0 -1
| @@ -29,7 +29,6 @@ unknown = unknown | |||
| 29 | typing_one = {name} is typing… | 29 | typing_one = {name} is typing… |
| 30 | typing_many = {count} people are typing… | 30 | typing_many = {count} people are typing… |
| 31 | new_messages = {count} new messages | 31 | new_messages = {count} new messages |
| 32 | -people = People | ||
| 33 | send = Send | 32 | send = Send |
| 34 | ghost_title = Speak as ghost? | 33 | ghost_title = Speak as ghost? |
| 35 | ghost_hint = Everyone in the call will hear you. | 34 | ghost_hint = Everyone in the call will hear you. |
crates/client/lang/tr/chat.txtmodified+0 -1
| @@ -29,7 +29,6 @@ unknown = bilinmiyor | |||
| 29 | typing_one = {name} yazıyor… | 29 | typing_one = {name} yazıyor… |
| 30 | typing_many = {count} kişi yazıyor… | 30 | typing_many = {count} kişi yazıyor… |
| 31 | new_messages = {count} yeni mesaj | 31 | new_messages = {count} yeni mesaj |
| 32 | -people = Kişiler | ||
| 33 | send = Gönder | 32 | send = Gönder |
| 34 | ghost_title = Hayalet olarak konuş? | 33 | ghost_title = Hayalet olarak konuş? |
| 35 | ghost_hint = Aramadaki herkes seni duyacak. | 34 | ghost_hint = Aramadaki herkes seni duyacak. |
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+16 -26
| @@ -271,7 +271,6 @@ pub struct Chat { | |||
| 271 | pub(super) followed: Option<(Id, common::stats::Stats)>, | 271 | pub(super) followed: Option<(Id, common::stats::Stats)>, |
| 272 | pub(super) share_loss: HashMap<(Id, Kind), VecDeque<f32>>, | 272 | pub(super) share_loss: HashMap<(Id, Kind), VecDeque<f32>>, |
| 273 | pub(super) stats_at: Option<StatsAt>, | 273 | pub(super) stats_at: Option<StatsAt>, |
| 274 | - pub(super) members_open: bool, | ||
| 275 | pub(super) offline_open: bool, | 274 | pub(super) offline_open: bool, |
| 276 | pub(super) usage_monitor: crate::usage::Monitor, | 275 | pub(super) usage_monitor: crate::usage::Monitor, |
| 277 | pub(super) ringing: HashSet<Id>, | 276 | pub(super) ringing: HashSet<Id>, |
| @@ -558,7 +557,6 @@ impl Chat { | |||
| 558 | followed: None, | 557 | followed: None, |
| 559 | share_loss: HashMap::new(), | 558 | share_loss: HashMap::new(), |
| 560 | stats_at: None, | 559 | stats_at: None, |
| 561 | - members_open: true, | ||
| 562 | offline_open: false, | 560 | offline_open: false, |
| 563 | usage_monitor: { | 561 | usage_monitor: { |
| 564 | let monitor = crate::usage::Monitor::default(); | 562 | let monitor = crate::usage::Monitor::default(); |
| @@ -1547,30 +1545,22 @@ impl Yumush { | |||
| 1547 | .child(title), | 1545 | .child(title), |
| 1548 | ) | 1546 | ) |
| 1549 | .into_any_element(), | 1547 | .into_any_element(), |
| 1550 | - (None, Some(room)) => clickable( | 1548 | + (None, Some(room)) => super::community_card::community_popover( |
| 1551 | - "room_title", | ||
| 1552 | - palette, | ||
| 1553 | - entity_action(entity, |yumush, _, cx| { | ||
| 1554 | - yumush.chat.members_open = !yumush.chat.members_open; | ||
| 1555 | - cx.notify(); | ||
| 1556 | - }), | ||
| 1557 | - ) | ||
| 1558 | - .tip(w().chat.people) | ||
| 1559 | - .flex() | ||
| 1560 | - .items_center() | ||
| 1561 | - .gap(px(space::SM)) | ||
| 1562 | - .child(super::community_icon( | ||
| 1563 | - palette, | ||
| 1564 | room, | 1549 | room, |
| 1565 | - px(size::AVATAR), | 1550 | + entity, |
| 1566 | - super::text(super::style::text::CAPTION), | 1551 | + div() |
| 1567 | - &self.chat.avatars, | 1552 | + .cursor_pointer() |
| 1568 | - )) | 1553 | + .flex() |
| 1569 | - .child(title) | 1554 | + .items_center() |
| 1570 | - .child( | 1555 | + .gap(px(space::SM)) |
| 1571 | - Icon::new(IconName::ChevronDown) | 1556 | + .child(super::community_icon( |
| 1572 | - .size(px(size::ICON_SM)) | 1557 | + palette, |
| 1573 | - .text_color(palette.tokens.faint()), | 1558 | + room, |
| 1559 | + px(size::AVATAR), | ||
| 1560 | + super::text(super::style::text::CAPTION), | ||
| 1561 | + &self.chat.avatars, | ||
| 1562 | + )) | ||
| 1563 | + .child(title), | ||
| 1574 | ) | 1564 | ) |
| 1575 | .into_any_element(), | 1565 | .into_any_element(), |
| 1576 | _ => div() | 1566 | _ => div() |
| @@ -3001,7 +2991,7 @@ fn members_column( | |||
| 3001 | let group = chat | 2991 | let group = chat |
| 3002 | .selected_community() | 2992 | .selected_community() |
| 3003 | .is_some_and(|community| matches!(community.kind, CommunityKind::Group)); | 2993 | .is_some_and(|community| matches!(community.kind, CommunityKind::Group)); |
| 3004 | - if !chat.members_open || !group { | 2994 | + if !group { |
| 3005 | return None; | 2995 | return None; |
| 3006 | } | 2996 | } |
| 3007 | let voice = chat.voice_ids(community_id); | 2997 | let voice = chat.voice_ids(community_id); |
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 | +} | ||