Builder user friends open as a searchable pop menu from an 'N friends' button
Browse files at this commitc0dbf85dfe2668bf20e52b9f7f020f534322d6f8Parent: e83914a- style
- builder user friends open as a searchable pop menu from an 'N friends' button
3 changed files +71 -51
- crates/client/lang/en/builder_users.txt +1 -0
- crates/client/lang/tr/builder_users.txt +1 -0
- crates/client/src/gui/builder/users.rs +69 -51
crates/client/lang/en/builder_users.txtmodified+1 -0
| @@ -47,3 +47,4 @@ group_danger = Danger | |||
| 47 | group_sessions = Sessions | 47 | group_sessions = Sessions |
| 48 | group_friends = Friends | 48 | group_friends = Friends |
| 49 | tag_builder = Builder | 49 | tag_builder = Builder |
| 50 | +friends_count = {count} friends | ||
crates/client/lang/tr/builder_users.txtmodified+1 -0
| @@ -47,3 +47,4 @@ group_danger = Tehlike | |||
| 47 | group_sessions = Oturumlar | 47 | group_sessions = Oturumlar |
| 48 | group_friends = Arkadaşlar | 48 | group_friends = Arkadaşlar |
| 49 | tag_builder = Kurucu | 49 | tag_builder = Kurucu |
| 50 | +friends_count = {count} arkadaş | ||
crates/client/src/gui/builder/users.rsmodified+69 -51
| @@ -13,10 +13,10 @@ use common::{ | |||
| 13 | time::{DAY_MILLIS, HOUR_MILLIS, MINUTE_MILLIS, now_ms}, | 13 | time::{DAY_MILLIS, HOUR_MILLIS, MINUTE_MILLIS, now_ms}, |
| 14 | }; | 14 | }; |
| 15 | use gpui_kit::{ | 15 | use gpui_kit::{ |
| 16 | - AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement as _, IntoElement, | 16 | + Anchor, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement as _, |
| 17 | - ParentElement, StatefulInteractiveElement as _, Styled, Window, | 17 | + IntoElement, ParentElement, StatefulInteractiveElement as _, Styled, Window, |
| 18 | assets::IconName, | 18 | assets::IconName, |
| 19 | - component::{Icon, input::Input}, | 19 | + component::{Icon, input::Input, popover::Popover}, |
| 20 | div, | 20 | div, |
| 21 | prelude::FluentBuilder as _, | 21 | prelude::FluentBuilder as _, |
| 22 | px, | 22 | px, |
| @@ -578,61 +578,79 @@ impl Yumush { | |||
| 578 | )) | 578 | )) |
| 579 | } | 579 | } |
| 580 | 580 | ||
| 581 | - fn builder_friend_list(&self, palette: Palette, cx: &App) -> Vec<AnyElement> { | 581 | + fn builder_friend_list(&self, palette: Palette) -> Vec<AnyElement> { |
| 582 | - if self.chat.builder_friends.is_empty() { | 582 | + let friends = self.chat.builder_friends.clone(); |
| 583 | + if friends.is_empty() { | ||
| 583 | return Vec::new(); | 584 | return Vec::new(); |
| 584 | } | 585 | } |
| 585 | - let query = crate::gui::widget::search_text(&self.chat.builder_friend_search, cx); | 586 | + let search = self.chat.builder_friend_search.clone(); |
| 587 | + let avatars = self.chat.avatars.clone(); | ||
| 588 | + let label = w().builder_users.friends_count(friends.len()); | ||
| 589 | + | ||
| 586 | vec![ | 590 | vec![ |
| 587 | - div() | 591 | + Popover::new("builder_friends") |
| 588 | - .w_full() | 592 | + .anchor(Anchor::TopLeft) |
| 589 | - .flex() | 593 | + .appearance(false) |
| 590 | - .flex_col() | 594 | + .trigger(crate::gui::Trigger::new( |
| 591 | - .gap(px(space::XS)) | 595 | + clickable("builder_friends_trigger", palette, |_, _| {}) |
| 592 | - .child(crate::gui::sidebar::input_box( | 596 | + .h(px(size::CONTROL_SM)) |
| 593 | - &self.chat.builder_friend_search, | ||
| 594 | - palette, | ||
| 595 | - )) | ||
| 596 | - .child( | ||
| 597 | - div() | ||
| 598 | - .id("builder_friends") | ||
| 599 | - .max_h(px(FRIENDS_MAX_H)) | ||
| 600 | - .overflow_y_scroll() | ||
| 601 | .flex() | 597 | .flex() |
| 602 | - .flex_col() | 598 | + .items_center() |
| 603 | - .children( | 599 | + .gap(px(space::SM)) |
| 604 | - self.chat | 600 | + .rounded(px(radius::MD)) |
| 605 | - .builder_friends | 601 | + .text_size(text(text::CAPTION)) |
| 606 | - .iter() | 602 | + .font_weight(FontWeight::MEDIUM) |
| 607 | - .filter(|friend| friend.username.to_lowercase().contains(&query)) | 603 | + .text_color(palette.text) |
| 608 | - .map(|friend| self.builder_friend_chip(friend, palette)), | 604 | + .child(Icon::new(IconName::Users).size(px(size::ICON_SM))) |
| 609 | - ), | 605 | + .child(label) |
| 610 | - ) | 606 | + .child(Icon::new(IconName::ChevronDown).size(px(size::ICON_SM))), |
| 607 | + )) | ||
| 608 | + .content(move |_, _, cx| { | ||
| 609 | + let query = crate::gui::widget::search_text(&search, cx); | ||
| 610 | + crate::gui::parts::popover(palette.tokens) | ||
| 611 | + .w(px(size::POPOVER)) | ||
| 612 | + .p(px(space::SM)) | ||
| 613 | + .gap(px(space::XS)) | ||
| 614 | + .child(crate::gui::sidebar::input_box(&search, palette)) | ||
| 615 | + .child( | ||
| 616 | + div() | ||
| 617 | + .id("builder_friends_list") | ||
| 618 | + .max_h(px(FRIENDS_MAX_H)) | ||
| 619 | + .overflow_y_scroll() | ||
| 620 | + .flex() | ||
| 621 | + .flex_col() | ||
| 622 | + .children( | ||
| 623 | + friends | ||
| 624 | + .iter() | ||
| 625 | + .filter(|friend| { | ||
| 626 | + friend.username.to_lowercase().contains(&query) | ||
| 627 | + }) | ||
| 628 | + .map(|friend| { | ||
| 629 | + div() | ||
| 630 | + .h(px(size::CONTROL_SM)) | ||
| 631 | + .flex() | ||
| 632 | + .items_center() | ||
| 633 | + .gap(px(space::SM)) | ||
| 634 | + .child(crate::gui::avatar( | ||
| 635 | + palette, | ||
| 636 | + friend, | ||
| 637 | + px(size::ICON), | ||
| 638 | + text(text::CAPTION), | ||
| 639 | + &avatars, | ||
| 640 | + )) | ||
| 641 | + .child( | ||
| 642 | + div() | ||
| 643 | + .text_size(text(text::CAPTION)) | ||
| 644 | + .child(friend.username.clone()), | ||
| 645 | + ) | ||
| 646 | + }), | ||
| 647 | + ), | ||
| 648 | + ) | ||
| 649 | + }) | ||
| 611 | .into_any_element(), | 650 | .into_any_element(), |
| 612 | ] | 651 | ] |
| 613 | } | 652 | } |
| 614 | 653 | ||
| 615 | - fn builder_friend_chip(&self, friend: &User, palette: Palette) -> AnyElement { | ||
| 616 | - div() | ||
| 617 | - .h(px(size::CONTROL_SM)) | ||
| 618 | - .flex() | ||
| 619 | - .items_center() | ||
| 620 | - .gap(px(space::SM)) | ||
| 621 | - .child(crate::gui::avatar( | ||
| 622 | - palette, | ||
| 623 | - friend, | ||
| 624 | - px(size::ICON), | ||
| 625 | - text(text::CAPTION), | ||
| 626 | - &self.chat.avatars, | ||
| 627 | - )) | ||
| 628 | - .child( | ||
| 629 | - div() | ||
| 630 | - .text_size(text(text::CAPTION)) | ||
| 631 | - .child(friend.username.clone()), | ||
| 632 | - ) | ||
| 633 | - .into_any_element() | ||
| 634 | - } | ||
| 635 | - | ||
| 636 | pub(super) fn builder_session_row( | 654 | pub(super) fn builder_session_row( |
| 637 | &self, | 655 | &self, |
| 638 | user_id: Id, | 656 | user_id: Id, |
| @@ -1140,7 +1158,7 @@ impl Yumush { | |||
| 1140 | .children(action_group( | 1158 | .children(action_group( |
| 1141 | w().builder_users.group_friends, | 1159 | w().builder_users.group_friends, |
| 1142 | palette, | 1160 | palette, |
| 1143 | - self.builder_friend_list(palette, cx), | 1161 | + self.builder_friend_list(palette), |
| 1144 | )) | 1162 | )) |
| 1145 | .children(stats_open.map(|stats| { | 1163 | .children(stats_open.map(|stats| { |
| 1146 | super::super::voice_stats::stats_panel( | 1164 | super::super::voice_stats::stats_panel( |