Pen next to your status in the profile card edits it in place (underlined input, Enter saves)
Browse files at this commit8b9990837cadbe1feb717d5f3d5d9907dbff38bcParent: 247bfb2- feat
- pen next to your status in the profile card edits it in place (underlined input, Enter saves)
3 changed files +83 -6
- crates/client/src/gui/chat.rs +1 -0
- crates/client/src/gui/profile.rs +80 -6
- crates/client/src/gui/settings_page.rs +2 -0
crates/client/src/gui/chat.rsmodified+1 -0
| @@ -127,6 +127,7 @@ pub enum CardMenu { | |||
| 127 | More, | 127 | More, |
| 128 | Accounts, | 128 | Accounts, |
| 129 | Presence, | 129 | Presence, |
| 130 | + Status, | ||
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | pub struct Chat { | 133 | pub struct Chat { |
crates/client/src/gui/profile.rsmodified+80 -6
| @@ -1,4 +1,5 @@ | |||
| 1 | use common::model::Id; | 1 | use common::model::Id; |
| 2 | +use gpui_kit::prelude::FluentBuilder as _; | ||
| 2 | use std::collections::VecDeque; | 3 | use std::collections::VecDeque; |
| 3 | use std::{collections::HashMap, sync::Arc}; | 4 | use std::{collections::HashMap, sync::Arc}; |
| 4 | 5 | ||
| @@ -28,8 +29,8 @@ use super::social::Relation; | |||
| 28 | use super::style::{radius, size, space, stroke, text}; | 29 | use super::style::{radius, size, space, stroke, text}; |
| 29 | use super::widget::spawn_done; | 30 | use super::widget::spawn_done; |
| 30 | use super::{ | 31 | use super::{ |
| 31 | - DAY_YEAR, Palette, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, | 32 | + DAY_YEAR, Palette, Tooltip as _, Trigger, Yumush, avatar, clickable, entity_action, |
| 32 | - millis_time, notify_error, palette, presence_color, rank_tag, text, | 33 | + input_dialog, millis_time, notify_error, palette, presence_color, rank_tag, text, |
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | const ACCOUNTS_MAX_H: f32 = 180.; | 36 | const ACCOUNTS_MAX_H: f32 = 180.; |
| @@ -105,6 +106,7 @@ pub(super) fn profile_popover( | |||
| 105 | confirming: yumush.chat.pending_user_delete == Some(user.id), | 106 | confirming: yumush.chat.pending_user_delete == Some(user.id), |
| 106 | reporting: yumush.chat.report == Some(ReportTarget::User(user.id)), | 107 | reporting: yumush.chat.report == Some(ReportTarget::User(user.id)), |
| 107 | reason: yumush.chat.report_reason.clone(), | 108 | reason: yumush.chat.report_reason.clone(), |
| 109 | + status: yumush.chat.status_input.clone(), | ||
| 108 | others: yumush | 110 | others: yumush |
| 109 | .accounts | 111 | .accounts |
| 110 | .others() | 112 | .others() |
| @@ -146,6 +148,7 @@ struct Card { | |||
| 146 | confirming: bool, | 148 | confirming: bool, |
| 147 | reporting: bool, | 149 | reporting: bool, |
| 148 | reason: Entity<InputState>, | 150 | reason: Entity<InputState>, |
| 151 | + status: Entity<InputState>, | ||
| 149 | others: Vec<(Id, String)>, | 152 | others: Vec<(Id, String)>, |
| 150 | volume: Option<(Entity<SliderState>, f32)>, | 153 | volume: Option<(Entity<SliderState>, f32)>, |
| 151 | } | 154 | } |
| @@ -308,6 +311,7 @@ impl Card { | |||
| 308 | ) | 311 | ) |
| 309 | .child( | 312 | .child( |
| 310 | stack(space::XXS) | 313 | stack(space::XXS) |
| 314 | + .flex_1() | ||
| 311 | .min_w_0() | 315 | .min_w_0() |
| 312 | .child( | 316 | .child( |
| 313 | band(space::SM) | 317 | band(space::SM) |
| @@ -322,9 +326,52 @@ impl Card { | |||
| 322 | ) | 326 | ) |
| 323 | .children(rank_tag(self.target, palette)), | 327 | .children(rank_tag(self.target, palette)), |
| 324 | ) | 328 | ) |
| 325 | - .children((!self.user.status.is_empty()).then(|| { | 329 | + .map(|names| { |
| 326 | - words(self.user.status.clone(), Text::Caption, Ink::Dim, t) | 330 | + if !is_self { |
| 327 | - })), | 331 | + return names.children((!self.user.status.is_empty()).then( |
| 332 | + || { | ||
| 333 | + words( | ||
| 334 | + self.user.status.clone(), | ||
| 335 | + Text::Caption, | ||
| 336 | + Ink::Dim, | ||
| 337 | + t, | ||
| 338 | + ) | ||
| 339 | + }, | ||
| 340 | + )); | ||
| 341 | + } | ||
| 342 | + if self.card_menu == CardMenu::Status { | ||
| 343 | + return names.child( | ||
| 344 | + div() | ||
| 345 | + .border_b(px(stroke::LINE)) | ||
| 346 | + .border_color(t.paper()) | ||
| 347 | + .child( | ||
| 348 | + super::widget::bare_input( | ||
| 349 | + palette, | ||
| 350 | + gpui_kit::component::input::Input::new( | ||
| 351 | + &self.status, | ||
| 352 | + ), | ||
| 353 | + ) | ||
| 354 | + .text_size(text(text::CAPTION)) | ||
| 355 | + .px_0() | ||
| 356 | + .w_full(), | ||
| 357 | + ), | ||
| 358 | + ); | ||
| 359 | + } | ||
| 360 | + names.child( | ||
| 361 | + band(space::XS) | ||
| 362 | + .children((!self.user.status.is_empty()).then(|| { | ||
| 363 | + words( | ||
| 364 | + self.user.status.clone(), | ||
| 365 | + Text::Caption, | ||
| 366 | + Ink::Dim, | ||
| 367 | + t, | ||
| 368 | + ) | ||
| 369 | + .min_w_0() | ||
| 370 | + .truncate() | ||
| 371 | + })) | ||
| 372 | + .child(edit_status(entity, &self.user.status, palette)), | ||
| 373 | + ) | ||
| 374 | + }), | ||
| 328 | ), | 375 | ), |
| 329 | ) | 376 | ) |
| 330 | .children(self.call.is_some().then(|| { | 377 | .children(self.call.is_some().then(|| { |
| @@ -469,7 +516,9 @@ fn self_rows( | |||
| 469 | palette: Palette, | 516 | palette: Palette, |
| 470 | ) -> Vec<AnyElement> { | 517 | ) -> Vec<AnyElement> { |
| 471 | match card_menu { | 518 | match card_menu { |
| 472 | - CardMenu::Main | CardMenu::More => main_self_rows(presence, entity, popover, palette), | 519 | + CardMenu::Main | CardMenu::More | CardMenu::Status => { |
| 520 | + main_self_rows(presence, entity, popover, palette) | ||
| 521 | + } | ||
| 473 | CardMenu::Accounts => accounts_rows(others, entity, popover, palette), | 522 | CardMenu::Accounts => accounts_rows(others, entity, popover, palette), |
| 474 | CardMenu::Presence => presence_rows(entity, palette), | 523 | CardMenu::Presence => presence_rows(entity, palette), |
| 475 | } | 524 | } |
| @@ -604,6 +653,31 @@ fn presence_rows(entity: &Entity<Yumush>, palette: Palette) -> Vec<AnyElement> { | |||
| 604 | rows | 653 | rows |
| 605 | } | 654 | } |
| 606 | 655 | ||
| 656 | +fn edit_status(entity: &Entity<Yumush>, status: &str, palette: Palette) -> impl IntoElement { | ||
| 657 | + let status = status.to_string(); | ||
| 658 | + clickable( | ||
| 659 | + "edit_status", | ||
| 660 | + palette, | ||
| 661 | + entity_action(entity, move |yumush, window, cx| { | ||
| 662 | + yumush.chat.card_menu = CardMenu::Status; | ||
| 663 | + yumush.chat.status_input.update(cx, |input, cx| { | ||
| 664 | + input.set_value(status.clone(), window, cx); | ||
| 665 | + input.focus(window, cx); | ||
| 666 | + }); | ||
| 667 | + cx.notify(); | ||
| 668 | + }), | ||
| 669 | + ) | ||
| 670 | + .tip("Edit status") | ||
| 671 | + .flex_none() | ||
| 672 | + .p(px(space::XXS)) | ||
| 673 | + .rounded(px(radius::SM)) | ||
| 674 | + .child( | ||
| 675 | + Icon::new(IconName::Pencil) | ||
| 676 | + .size(px(size::ICON_SM)) | ||
| 677 | + .text_color(palette.tokens.faint()), | ||
| 678 | + ) | ||
| 679 | +} | ||
| 680 | + | ||
| 607 | fn card_menu_action( | 681 | fn card_menu_action( |
| 608 | entity: &Entity<Yumush>, | 682 | entity: &Entity<Yumush>, |
| 609 | menu: CardMenu, | 683 | menu: CardMenu, |
crates/client/src/gui/settings_page.rsmodified+2 -0
| @@ -249,6 +249,8 @@ impl Yumush { | |||
| 249 | pub(super) fn save_status(&mut self, window: &mut Window, cx: &mut Context<Self>) { | 249 | pub(super) fn save_status(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 250 | let status = self.chat.status_input.read(cx).text().to_string(); | 250 | let status = self.chat.status_input.read(cx).text().to_string(); |
| 251 | let network = self.network.clone(); | 251 | let network = self.network.clone(); |
| 252 | + self.chat.card_menu = super::chat::CardMenu::Main; | ||
| 253 | + cx.notify(); | ||
| 252 | 254 | ||
| 253 | cx.spawn_in(window, async move |this, cx| { | 255 | cx.spawn_in(window, async move |this, cx| { |
| 254 | let result = network.call(UpdateStatus { status }).await; | 256 | let result = network.call(UpdateStatus { status }).await; |