Profile card in the quiet-rooms shape (picture beside name and status, their line in a call, one faint 'in X · joined' line, volume row, Message with the rest behind …)
Browse files at this commit654d396ea8501ee92959ee870b277306690de698Parent: 1593b29- feat
- profile card in the quiet-rooms shape (picture beside name and status, their line in a call, one faint 'in X · joined' line, volume row, Message with the rest behind …)
3 changed files +95 -69
- crates/client/src/gui/chat.rs +1 -0
- crates/client/src/gui/profile.rs +93 -68
- crates/client/src/gui/sidebar.rs +1 -1
crates/client/src/gui/chat.rsmodified+1 -0
| @@ -121,6 +121,7 @@ pub enum ReportTarget { | |||
| 121 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 121 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 122 | pub enum CardMenu { | 122 | pub enum CardMenu { |
| 123 | Main, | 123 | Main, |
| 124 | + More, | ||
| 124 | Accounts, | 125 | Accounts, |
| 125 | Presence, | 126 | Presence, |
| 126 | } | 127 | } |
crates/client/src/gui/profile.rsmodified+93 -68
| @@ -1,4 +1,5 @@ | |||
| 1 | use common::model::Id; | 1 | use common::model::Id; |
| 2 | +use std::collections::VecDeque; | ||
| 2 | use std::{collections::HashMap, sync::Arc}; | 3 | use std::{collections::HashMap, sync::Arc}; |
| 3 | 4 | ||
| 4 | use common::{ | 5 | use common::{ |
| @@ -22,9 +23,10 @@ use gpui_kit::{ | |||
| 22 | 23 | ||
| 23 | use super::chat::{CardMenu, ReportTarget, View}; | 24 | use super::chat::{CardMenu, ReportTarget, View}; |
| 24 | use super::message_actions::report_bar; | 25 | use super::message_actions::report_bar; |
| 26 | +use super::parts::{Ink, Text, Tone, Voice, band, icon_button, stack, voice_line, words}; | ||
| 25 | use super::social::Relation; | 27 | use super::social::Relation; |
| 26 | use super::style::{radius, size, space, stroke, text}; | 28 | use super::style::{radius, size, space, stroke, text}; |
| 27 | -use super::widget::{panel, spawn_done}; | 29 | +use super::widget::spawn_done; |
| 28 | use super::{ | 30 | use super::{ |
| 29 | DAY_YEAR, Palette, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, | 31 | DAY_YEAR, Palette, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, |
| 30 | millis_time, notify_error, palette, presence_color, rank_tag, text, | 32 | millis_time, notify_error, palette, presence_color, rank_tag, text, |
| @@ -114,6 +116,15 @@ pub(super) fn profile_popover( | |||
| 114 | .as_ref() | 116 | .as_ref() |
| 115 | .filter(|volume| volume.user_id == user.id) | 117 | .filter(|volume| volume.user_id == user.id) |
| 116 | .map(|volume| (volume.slider.clone(), yumush.user_volume(user.id))), | 118 | .map(|volume| (volume.slider.clone(), yumush.user_volume(user.id))), |
| 119 | + call: yumush.call_of(user.id).map(|community| { | ||
| 120 | + if community.kind.is_direct() { | ||
| 121 | + "a call".to_string() | ||
| 122 | + } else { | ||
| 123 | + community.name.clone() | ||
| 124 | + } | ||
| 125 | + }), | ||
| 126 | + wave: yumush.chat.waves.voice(user.id).cloned(), | ||
| 127 | + speaking: yumush.chat.waves.speaking.contains(&user.id), | ||
| 117 | user: user.clone(), | 128 | user: user.clone(), |
| 118 | }; | 129 | }; |
| 119 | 130 | ||
| @@ -123,6 +134,9 @@ pub(super) fn profile_popover( | |||
| 123 | 134 | ||
| 124 | struct Card { | 135 | struct Card { |
| 125 | user: User, | 136 | user: User, |
| 137 | + call: Option<String>, | ||
| 138 | + wave: Option<VecDeque<f32>>, | ||
| 139 | + speaking: bool, | ||
| 126 | viewer: Option<User>, | 140 | viewer: Option<User>, |
| 127 | actor: Option<Rank>, | 141 | actor: Option<Rank>, |
| 128 | target: Option<Rank>, | 142 | target: Option<Rank>, |
| @@ -205,6 +219,7 @@ impl Card { | |||
| 205 | .viewer | 219 | .viewer |
| 206 | .as_ref() | 220 | .as_ref() |
| 207 | .is_some_and(|viewer| viewer.id == self.user.id); | 221 | .is_some_and(|viewer| viewer.id == self.user.id); |
| 222 | + let t = palette.tokens; | ||
| 208 | let rows = if is_self { | 223 | let rows = if is_self { |
| 209 | self_rows( | 224 | self_rows( |
| 210 | &self.others, | 225 | &self.others, |
| @@ -217,88 +232,98 @@ impl Card { | |||
| 217 | } else { | 232 | } else { |
| 218 | let mut rows = self.social_rows(entity, &popover, palette); | 233 | let mut rows = self.social_rows(entity, &popover, palette); |
| 219 | rows.extend(self.moderation_rows(entity, &popover, palette)); | 234 | rows.extend(self.moderation_rows(entity, &popover, palette)); |
| 220 | - rows | 235 | + if self.card_menu == CardMenu::More || rows.len() < 2 { |
| 236 | + rows | ||
| 237 | + } else { | ||
| 238 | + let first = rows.remove(0); | ||
| 239 | + vec![ | ||
| 240 | + band(space::XS) | ||
| 241 | + .child(div().flex_1().child(first)) | ||
| 242 | + .child(icon_button( | ||
| 243 | + "profile_more", | ||
| 244 | + IconName::Ellipsis, | ||
| 245 | + "More", | ||
| 246 | + Tone::Idle, | ||
| 247 | + t, | ||
| 248 | + card_menu_action(entity, CardMenu::More), | ||
| 249 | + )) | ||
| 250 | + .into_any_element(), | ||
| 251 | + ] | ||
| 252 | + } | ||
| 253 | + }; | ||
| 254 | + let doing = match (&self.call, is_self) { | ||
| 255 | + (Some(room), _) => format!("in {room}"), | ||
| 256 | + (None, true) => String::new(), | ||
| 257 | + (None, false) => self.presence.label().to_lowercase(), | ||
| 258 | + }; | ||
| 259 | + let joined = format!("joined {}", millis_time(self.user.created_at, DAY_YEAR)); | ||
| 260 | + let about = if doing.is_empty() { | ||
| 261 | + joined | ||
| 262 | + } else { | ||
| 263 | + format!("{doing} · {joined}") | ||
| 221 | }; | 264 | }; |
| 222 | - let divider = (!rows.is_empty()).then(|| { | ||
| 223 | - div() | ||
| 224 | - .h(px(stroke::LINE)) | ||
| 225 | - .my(px(space::XS)) | ||
| 226 | - .bg(palette.border) | ||
| 227 | - }); | ||
| 228 | 265 | ||
| 229 | - panel(palette) | 266 | + super::parts::popover(t) |
| 230 | - .w(px(size::SIDEBAR)) | 267 | + .w(px(size::POPOVER)) |
| 231 | - .p(px(space::LG)) | 268 | + .gap(px(space::LG)) |
| 232 | - .flex() | ||
| 233 | - .flex_col() | ||
| 234 | - .gap(px(space::MD)) | ||
| 235 | - .child(avatar( | ||
| 236 | - palette, | ||
| 237 | - &self.user, | ||
| 238 | - px(size::AVATAR_LG), | ||
| 239 | - text(text::BODY), | ||
| 240 | - avatars, | ||
| 241 | - )) | ||
| 242 | .child( | 269 | .child( |
| 243 | - div() | 270 | + band(space::LG) |
| 244 | - .flex() | 271 | + .child(avatar( |
| 245 | - .items_center() | 272 | + palette, |
| 246 | - .gap(px(space::SM)) | 273 | + &self.user, |
| 274 | + px(size::AVATAR_LG), | ||
| 275 | + text(text::BODY), | ||
| 276 | + avatars, | ||
| 277 | + )) | ||
| 247 | .child( | 278 | .child( |
| 248 | - div() | 279 | + stack(space::XXS) |
| 249 | - .text_size(text(text::UI)) | 280 | + .min_w_0() |
| 250 | - .font_weight(FontWeight::SEMIBOLD) | 281 | + .child( |
| 251 | - .child(self.user.username.clone()), | 282 | + band(space::SM) |
| 252 | - ) | 283 | + .child( |
| 253 | - .children(rank_tag(self.target, palette)), | 284 | + words( |
| 285 | + self.user.username.clone(), | ||
| 286 | + Text::Body, | ||
| 287 | + Ink::Paper, | ||
| 288 | + t, | ||
| 289 | + ) | ||
| 290 | + .font_weight(FontWeight::MEDIUM), | ||
| 291 | + ) | ||
| 292 | + .children(rank_tag(self.target, palette)), | ||
| 293 | + ) | ||
| 294 | + .children((!self.user.status.is_empty()).then(|| { | ||
| 295 | + words(self.user.status.clone(), Text::Caption, Ink::Dim, t) | ||
| 296 | + })), | ||
| 297 | + ), | ||
| 254 | ) | 298 | ) |
| 255 | - .children((!is_self).then(|| { | 299 | + .children(self.call.is_some().then(|| { |
| 256 | - div() | 300 | + div().h(px(space::MD)).child(voice_line( |
| 257 | - .flex() | 301 | + self.wave.as_ref(), |
| 258 | - .items_center() | 302 | + if self.speaking { |
| 259 | - .gap(px(space::SM)) | 303 | + Voice::Live(t.person(self.user.id)) |
| 260 | - .text_size(text(text::CAPTION)) | 304 | + } else { |
| 261 | - .text_color(palette.muted) | 305 | + Voice::Quiet |
| 262 | - .child(presence_dot(self.presence, palette)) | 306 | + }, |
| 263 | - .child(self.presence.label()) | 307 | + t, |
| 308 | + )) | ||
| 264 | })) | 309 | })) |
| 265 | - .children((!self.user.status.is_empty()).then(|| { | 310 | + .child(words(about, Text::Caption, Ink::Faint, t)) |
| 266 | - div() | ||
| 267 | - .text_size(text(text::CAPTION)) | ||
| 268 | - .text_color(palette.muted) | ||
| 269 | - .child(self.user.status.clone()) | ||
| 270 | - })) | ||
| 271 | - .child( | ||
| 272 | - div() | ||
| 273 | - .text_size(text(text::CAPTION)) | ||
| 274 | - .text_color(palette.muted) | ||
| 275 | - .child(format!( | ||
| 276 | - "Joined {}", | ||
| 277 | - millis_time(self.user.created_at, DAY_YEAR) | ||
| 278 | - )), | ||
| 279 | - ) | ||
| 280 | .children(self.volume.map(|(slider, volume)| { | 311 | .children(self.volume.map(|(slider, volume)| { |
| 281 | - div() | 312 | + band(space::MD) |
| 282 | - .flex() | 313 | + .child(words("Volume", Text::Label, Ink::Paper, t).flex_none()) |
| 283 | - .items_center() | ||
| 284 | - .gap(px(space::SM)) | ||
| 285 | - .text_size(text(text::CAPTION)) | ||
| 286 | - .text_color(palette.muted) | ||
| 287 | - .child(Icon::new(IconName::Volume2).size(px(size::ICON_SM))) | ||
| 288 | .child(Slider::new(&slider).flex_1()) | 314 | .child(Slider::new(&slider).flex_1()) |
| 289 | .child( | 315 | .child( |
| 290 | - div() | 316 | + words(format!("{volume:.0}%"), Text::Caption, Ink::Dim, t) |
| 291 | .w(px(size::CONTROL)) | 317 | .w(px(size::CONTROL)) |
| 292 | - .text_right() | 318 | + .text_right(), |
| 293 | - .child(format!("{volume:.0}%")), | ||
| 294 | ) | 319 | ) |
| 295 | })) | 320 | })) |
| 296 | .children( | 321 | .children( |
| 297 | self.reporting | 322 | self.reporting |
| 298 | .then(|| report_bar(&self.reason, entity, palette)), | 323 | .then(|| report_bar(&self.reason, entity, palette)), |
| 299 | ) | 324 | ) |
| 300 | - .children(divider) | 325 | + .children((!rows.is_empty()).then(|| div().h(px(stroke::LINE)).bg(palette.border))) |
| 301 | - .child(div().flex().flex_col().gap(px(space::MD)).children(rows)) | 326 | + .child(div().flex().flex_col().gap(px(space::XS)).children(rows)) |
| 302 | } | 327 | } |
| 303 | 328 | ||
| 304 | fn moderation_rows( | 329 | fn moderation_rows( |
| @@ -399,7 +424,7 @@ fn self_rows( | |||
| 399 | palette: Palette, | 424 | palette: Palette, |
| 400 | ) -> Vec<AnyElement> { | 425 | ) -> Vec<AnyElement> { |
| 401 | match card_menu { | 426 | match card_menu { |
| 402 | - CardMenu::Main => main_self_rows(presence, entity, popover, palette), | 427 | + CardMenu::Main | CardMenu::More => main_self_rows(presence, entity, popover, palette), |
| 403 | CardMenu::Accounts => accounts_rows(others, entity, popover, palette), | 428 | CardMenu::Accounts => accounts_rows(others, entity, popover, palette), |
| 404 | CardMenu::Presence => presence_rows(entity, palette), | 429 | CardMenu::Presence => presence_rows(entity, palette), |
| 405 | } | 430 | } |
crates/client/src/gui/sidebar.rsmodified+1 -1
| @@ -621,7 +621,7 @@ impl Yumush { | |||
| 621 | .collect() | 621 | .collect() |
| 622 | } | 622 | } |
| 623 | 623 | ||
| 624 | - fn call_of(&self, user_id: Id) -> Option<&Community> { | 624 | + pub(super) fn call_of(&self, user_id: Id) -> Option<&Community> { |
| 625 | let community_id = self | 625 | let community_id = self |
| 626 | .chat | 626 | .chat |
| 627 | .voice | 627 | .voice |