diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index ee6e50a..46dab2f 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -121,6 +121,7 @@ pub enum ReportTarget { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum CardMenu { Main, + More, Accounts, Presence, } diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index e0b727f..f2a5663 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -1,4 +1,5 @@ use common::model::Id; +use std::collections::VecDeque; use std::{collections::HashMap, sync::Arc}; use common::{ @@ -22,9 +23,10 @@ use gpui_kit::{ use super::chat::{CardMenu, ReportTarget, View}; use super::message_actions::report_bar; +use super::parts::{Ink, Text, Tone, Voice, band, icon_button, stack, voice_line, words}; use super::social::Relation; use super::style::{radius, size, space, stroke, text}; -use super::widget::{panel, spawn_done}; +use super::widget::spawn_done; use super::{ DAY_YEAR, Palette, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, millis_time, notify_error, palette, presence_color, rank_tag, text, @@ -114,6 +116,15 @@ pub(super) fn profile_popover( .as_ref() .filter(|volume| volume.user_id == user.id) .map(|volume| (volume.slider.clone(), yumush.user_volume(user.id))), + call: yumush.call_of(user.id).map(|community| { + if community.kind.is_direct() { + "a call".to_string() + } else { + community.name.clone() + } + }), + wave: yumush.chat.waves.voice(user.id).cloned(), + speaking: yumush.chat.waves.speaking.contains(&user.id), user: user.clone(), }; @@ -123,6 +134,9 @@ pub(super) fn profile_popover( struct Card { user: User, + call: Option, + wave: Option>, + speaking: bool, viewer: Option, actor: Option, target: Option, @@ -205,6 +219,7 @@ impl Card { .viewer .as_ref() .is_some_and(|viewer| viewer.id == self.user.id); + let t = palette.tokens; let rows = if is_self { self_rows( &self.others, @@ -217,88 +232,98 @@ impl Card { } else { let mut rows = self.social_rows(entity, &popover, palette); rows.extend(self.moderation_rows(entity, &popover, palette)); - rows + if self.card_menu == CardMenu::More || rows.len() < 2 { + rows + } else { + let first = rows.remove(0); + vec![ + band(space::XS) + .child(div().flex_1().child(first)) + .child(icon_button( + "profile_more", + IconName::Ellipsis, + "More", + Tone::Idle, + t, + card_menu_action(entity, CardMenu::More), + )) + .into_any_element(), + ] + } + }; + let doing = match (&self.call, is_self) { + (Some(room), _) => format!("in {room}"), + (None, true) => String::new(), + (None, false) => self.presence.label().to_lowercase(), + }; + let joined = format!("joined {}", millis_time(self.user.created_at, DAY_YEAR)); + let about = if doing.is_empty() { + joined + } else { + format!("{doing} ยท {joined}") }; - let divider = (!rows.is_empty()).then(|| { - div() - .h(px(stroke::LINE)) - .my(px(space::XS)) - .bg(palette.border) - }); - panel(palette) - .w(px(size::SIDEBAR)) - .p(px(space::LG)) - .flex() - .flex_col() - .gap(px(space::MD)) - .child(avatar( - palette, - &self.user, - px(size::AVATAR_LG), - text(text::BODY), - avatars, - )) + super::parts::popover(t) + .w(px(size::POPOVER)) + .gap(px(space::LG)) .child( - div() - .flex() - .items_center() - .gap(px(space::SM)) + band(space::LG) + .child(avatar( + palette, + &self.user, + px(size::AVATAR_LG), + text(text::BODY), + avatars, + )) .child( - div() - .text_size(text(text::UI)) - .font_weight(FontWeight::SEMIBOLD) - .child(self.user.username.clone()), - ) - .children(rank_tag(self.target, palette)), + stack(space::XXS) + .min_w_0() + .child( + band(space::SM) + .child( + words( + self.user.username.clone(), + Text::Body, + Ink::Paper, + t, + ) + .font_weight(FontWeight::MEDIUM), + ) + .children(rank_tag(self.target, palette)), + ) + .children((!self.user.status.is_empty()).then(|| { + words(self.user.status.clone(), Text::Caption, Ink::Dim, t) + })), + ), ) - .children((!is_self).then(|| { - div() - .flex() - .items_center() - .gap(px(space::SM)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(presence_dot(self.presence, palette)) - .child(self.presence.label()) + .children(self.call.is_some().then(|| { + div().h(px(space::MD)).child(voice_line( + self.wave.as_ref(), + if self.speaking { + Voice::Live(t.person(self.user.id)) + } else { + Voice::Quiet + }, + t, + )) })) - .children((!self.user.status.is_empty()).then(|| { - div() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(self.user.status.clone()) - })) - .child( - div() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(format!( - "Joined {}", - millis_time(self.user.created_at, DAY_YEAR) - )), - ) + .child(words(about, Text::Caption, Ink::Faint, t)) .children(self.volume.map(|(slider, volume)| { - div() - .flex() - .items_center() - .gap(px(space::SM)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(Icon::new(IconName::Volume2).size(px(size::ICON_SM))) + band(space::MD) + .child(words("Volume", Text::Label, Ink::Paper, t).flex_none()) .child(Slider::new(&slider).flex_1()) .child( - div() + words(format!("{volume:.0}%"), Text::Caption, Ink::Dim, t) .w(px(size::CONTROL)) - .text_right() - .child(format!("{volume:.0}%")), + .text_right(), ) })) .children( self.reporting .then(|| report_bar(&self.reason, entity, palette)), ) - .children(divider) - .child(div().flex().flex_col().gap(px(space::MD)).children(rows)) + .children((!rows.is_empty()).then(|| div().h(px(stroke::LINE)).bg(palette.border))) + .child(div().flex().flex_col().gap(px(space::XS)).children(rows)) } fn moderation_rows( @@ -399,7 +424,7 @@ fn self_rows( palette: Palette, ) -> Vec { match card_menu { - CardMenu::Main => main_self_rows(presence, entity, popover, palette), + CardMenu::Main | CardMenu::More => main_self_rows(presence, entity, popover, palette), CardMenu::Accounts => accounts_rows(others, entity, popover, palette), CardMenu::Presence => presence_rows(entity, palette), } diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 1d25f75..87f99c3 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -621,7 +621,7 @@ impl Yumush { .collect() } - fn call_of(&self, user_id: Id) -> Option<&Community> { + pub(super) fn call_of(&self, user_id: Id) -> Option<&Community> { let community_id = self .chat .voice