diff --git a/crates/client/lang/en/builder_users.txt b/crates/client/lang/en/builder_users.txt index 3ee3638..81ac469 100644 --- a/crates/client/lang/en/builder_users.txt +++ b/crates/client/lang/en/builder_users.txt @@ -47,3 +47,4 @@ group_danger = Danger group_sessions = Sessions group_friends = Friends tag_builder = Builder +friends_count = {count} friends diff --git a/crates/client/lang/tr/builder_users.txt b/crates/client/lang/tr/builder_users.txt index 76e325a..d1d2628 100644 --- a/crates/client/lang/tr/builder_users.txt +++ b/crates/client/lang/tr/builder_users.txt @@ -47,3 +47,4 @@ group_danger = Tehlike group_sessions = Oturumlar group_friends = Arkadaşlar tag_builder = Kurucu +friends_count = {count} arkadaş diff --git a/crates/client/src/gui/builder/users.rs b/crates/client/src/gui/builder/users.rs index 9e0b8ea..4b6b770 100644 --- a/crates/client/src/gui/builder/users.rs +++ b/crates/client/src/gui/builder/users.rs @@ -13,10 +13,10 @@ use common::{ time::{DAY_MILLIS, HOUR_MILLIS, MINUTE_MILLIS, now_ms}, }; use gpui_kit::{ - AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement as _, IntoElement, - ParentElement, StatefulInteractiveElement as _, Styled, Window, + Anchor, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement as _, + IntoElement, ParentElement, StatefulInteractiveElement as _, Styled, Window, assets::IconName, - component::{Icon, input::Input}, + component::{Icon, input::Input, popover::Popover}, div, prelude::FluentBuilder as _, px, @@ -578,61 +578,79 @@ impl Yumush { )) } - fn builder_friend_list(&self, palette: Palette, cx: &App) -> Vec { - if self.chat.builder_friends.is_empty() { + fn builder_friend_list(&self, palette: Palette) -> Vec { + let friends = self.chat.builder_friends.clone(); + if friends.is_empty() { return Vec::new(); } - let query = crate::gui::widget::search_text(&self.chat.builder_friend_search, cx); + let search = self.chat.builder_friend_search.clone(); + let avatars = self.chat.avatars.clone(); + let label = w().builder_users.friends_count(friends.len()); + vec![ - div() - .w_full() - .flex() - .flex_col() - .gap(px(space::XS)) - .child(crate::gui::sidebar::input_box( - &self.chat.builder_friend_search, - palette, - )) - .child( - div() - .id("builder_friends") - .max_h(px(FRIENDS_MAX_H)) - .overflow_y_scroll() + Popover::new("builder_friends") + .anchor(Anchor::TopLeft) + .appearance(false) + .trigger(crate::gui::Trigger::new( + clickable("builder_friends_trigger", palette, |_, _| {}) + .h(px(size::CONTROL_SM)) .flex() - .flex_col() - .children( - self.chat - .builder_friends - .iter() - .filter(|friend| friend.username.to_lowercase().contains(&query)) - .map(|friend| self.builder_friend_chip(friend, palette)), - ), - ) + .items_center() + .gap(px(space::SM)) + .rounded(px(radius::MD)) + .text_size(text(text::CAPTION)) + .font_weight(FontWeight::MEDIUM) + .text_color(palette.text) + .child(Icon::new(IconName::Users).size(px(size::ICON_SM))) + .child(label) + .child(Icon::new(IconName::ChevronDown).size(px(size::ICON_SM))), + )) + .content(move |_, _, cx| { + let query = crate::gui::widget::search_text(&search, cx); + crate::gui::parts::popover(palette.tokens) + .w(px(size::POPOVER)) + .p(px(space::SM)) + .gap(px(space::XS)) + .child(crate::gui::sidebar::input_box(&search, palette)) + .child( + div() + .id("builder_friends_list") + .max_h(px(FRIENDS_MAX_H)) + .overflow_y_scroll() + .flex() + .flex_col() + .children( + friends + .iter() + .filter(|friend| { + friend.username.to_lowercase().contains(&query) + }) + .map(|friend| { + div() + .h(px(size::CONTROL_SM)) + .flex() + .items_center() + .gap(px(space::SM)) + .child(crate::gui::avatar( + palette, + friend, + px(size::ICON), + text(text::CAPTION), + &avatars, + )) + .child( + div() + .text_size(text(text::CAPTION)) + .child(friend.username.clone()), + ) + }), + ), + ) + }) .into_any_element(), ] } - fn builder_friend_chip(&self, friend: &User, palette: Palette) -> AnyElement { - div() - .h(px(size::CONTROL_SM)) - .flex() - .items_center() - .gap(px(space::SM)) - .child(crate::gui::avatar( - palette, - friend, - px(size::ICON), - text(text::CAPTION), - &self.chat.avatars, - )) - .child( - div() - .text_size(text(text::CAPTION)) - .child(friend.username.clone()), - ) - .into_any_element() - } - pub(super) fn builder_session_row( &self, user_id: Id, @@ -1140,7 +1158,7 @@ impl Yumush { .children(action_group( w().builder_users.group_friends, palette, - self.builder_friend_list(palette, cx), + self.builder_friend_list(palette), )) .children(stats_open.map(|stats| { super::super::voice_stats::stats_panel(