Builder user friends are a searchable scroll list instead of an endless row
Browse files at this commit60fc310a4ddb9a976cc504866ac9b96db0fb18c7Parent: 4aba987- style
- builder user friends are a searchable scroll list instead of an endless row
2 changed files +49 -8
crates/client/src/gui/builder/users.rsmodified+40 -7
| @@ -13,7 +13,8 @@ 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, IntoElement, ParentElement, Styled, Window, | 16 | + AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement as _, IntoElement, |
| 17 | + ParentElement, StatefulInteractiveElement as _, Styled, Window, | ||
| 17 | assets::IconName, | 18 | assets::IconName, |
| 18 | component::{Icon, input::Input}, | 19 | component::{Icon, input::Input}, |
| 19 | div, | 20 | div, |
| @@ -36,6 +37,7 @@ use crate::{ | |||
| 36 | net::{Fail, NetworkHandle}, | 37 | net::{Fail, NetworkHandle}, |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| 40 | +const FRIENDS_MAX_H: f32 = 200.; | ||
| 39 | const MINUTES_PER_HOUR: u64 = HOUR_MILLIS / MINUTE_MILLIS; | 41 | const MINUTES_PER_HOUR: u64 = HOUR_MILLIS / MINUTE_MILLIS; |
| 40 | const MINUTES_PER_DAY: u64 = DAY_MILLIS / MINUTE_MILLIS; | 42 | const MINUTES_PER_DAY: u64 = DAY_MILLIS / MINUTE_MILLIS; |
| 41 | 43 | ||
| @@ -576,11 +578,46 @@ impl Yumush { | |||
| 576 | )) | 578 | )) |
| 577 | } | 579 | } |
| 578 | 580 | ||
| 581 | + fn builder_friend_list(&self, palette: Palette, cx: &App) -> Vec<AnyElement> { | ||
| 582 | + if self.chat.builder_friends.is_empty() { | ||
| 583 | + return Vec::new(); | ||
| 584 | + } | ||
| 585 | + let query = crate::gui::widget::search_text(&self.chat.builder_friend_search, cx); | ||
| 586 | + vec![ | ||
| 587 | + div() | ||
| 588 | + .w_full() | ||
| 589 | + .flex() | ||
| 590 | + .flex_col() | ||
| 591 | + .gap(px(space::XS)) | ||
| 592 | + .child(crate::gui::sidebar::input_box( | ||
| 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() | ||
| 602 | + .flex_col() | ||
| 603 | + .children( | ||
| 604 | + self.chat | ||
| 605 | + .builder_friends | ||
| 606 | + .iter() | ||
| 607 | + .filter(|friend| friend.username.to_lowercase().contains(&query)) | ||
| 608 | + .map(|friend| self.builder_friend_chip(friend, palette)), | ||
| 609 | + ), | ||
| 610 | + ) | ||
| 611 | + .into_any_element(), | ||
| 612 | + ] | ||
| 613 | + } | ||
| 614 | + | ||
| 579 | fn builder_friend_chip(&self, friend: &User, palette: Palette) -> AnyElement { | 615 | fn builder_friend_chip(&self, friend: &User, palette: Palette) -> AnyElement { |
| 580 | div() | 616 | div() |
| 617 | + .h(px(size::CONTROL_SM)) | ||
| 581 | .flex() | 618 | .flex() |
| 582 | .items_center() | 619 | .items_center() |
| 583 | - .gap(px(space::XS)) | 620 | + .gap(px(space::SM)) |
| 584 | .child(crate::gui::avatar( | 621 | .child(crate::gui::avatar( |
| 585 | palette, | 622 | palette, |
| 586 | friend, | 623 | friend, |
| @@ -1103,11 +1140,7 @@ impl Yumush { | |||
| 1103 | .children(action_group( | 1140 | .children(action_group( |
| 1104 | w().builder_users.group_friends, | 1141 | w().builder_users.group_friends, |
| 1105 | palette, | 1142 | palette, |
| 1106 | - self.chat | 1143 | + self.builder_friend_list(palette, cx), |
| 1107 | - .builder_friends | ||
| 1108 | - .iter() | ||
| 1109 | - .map(|friend| self.builder_friend_chip(friend, palette)) | ||
| 1110 | - .collect(), | ||
| 1111 | )) | 1144 | )) |
| 1112 | .children(stats_open.map(|stats| { | 1145 | .children(stats_open.map(|stats| { |
| 1113 | super::super::voice_stats::stats_panel( | 1146 | super::super::voice_stats::stats_panel( |
crates/client/src/gui/chat.rsmodified+9 -1
| @@ -235,6 +235,7 @@ pub struct Chat { | |||
| 235 | pub(super) builder_log_from: Entity<InputState>, | 235 | pub(super) builder_log_from: Entity<InputState>, |
| 236 | pub(super) builder_log_to: Entity<InputState>, | 236 | pub(super) builder_log_to: Entity<InputState>, |
| 237 | pub(super) builder_search: Entity<InputState>, | 237 | pub(super) builder_search: Entity<InputState>, |
| 238 | + pub(super) builder_friend_search: Entity<InputState>, | ||
| 238 | pub(super) builder_communities: Vec<CommunitySummary>, | 239 | pub(super) builder_communities: Vec<CommunitySummary>, |
| 239 | pub(super) builder_reports: Vec<Report>, | 240 | pub(super) builder_reports: Vec<Report>, |
| 240 | pub(super) report_filter: Option<ReportStatus>, | 241 | pub(super) report_filter: Option<ReportStatus>, |
| @@ -375,11 +376,17 @@ impl Chat { | |||
| 375 | let ban_search = new_input(w().chat.search, window, cx); | 376 | let ban_search = new_input(w().chat.search, window, cx); |
| 376 | let log_search = new_input(w().chat.search, window, cx); | 377 | let log_search = new_input(w().chat.search, window, cx); |
| 377 | let builder_search = new_input(w().chat.search, window, cx); | 378 | let builder_search = new_input(w().chat.search, window, cx); |
| 379 | + let builder_friend_search = new_input(w().chat.search, window, cx); | ||
| 378 | let builder_password = new_input(w().chat.new_password, window, cx); | 380 | let builder_password = new_input(w().chat.new_password, window, cx); |
| 379 | builder_password.update(cx, |input, cx| input.set_masked(true, window, cx)); | 381 | builder_password.update(cx, |input, cx| input.set_masked(true, window, cx)); |
| 380 | let new_password = new_input(w().chat.password, window, cx); | 382 | let new_password = new_input(w().chat.password, window, cx); |
| 381 | new_password.update(cx, |input, cx| input.set_masked(true, window, cx)); | 383 | new_password.update(cx, |input, cx| input.set_masked(true, window, cx)); |
| 382 | - for search in [&ban_search, &log_search, &builder_search] { | 384 | + for search in [ |
| 385 | + &ban_search, | ||
| 386 | + &log_search, | ||
| 387 | + &builder_search, | ||
| 388 | + &builder_friend_search, | ||
| 389 | + ] { | ||
| 383 | cx.subscribe_in(search, window, |_, _, event, window, cx| { | 390 | cx.subscribe_in(search, window, |_, _, event, window, cx| { |
| 384 | if matches!(event, InputEvent::Change) { | 391 | if matches!(event, InputEvent::Change) { |
| 385 | window.refresh(); | 392 | window.refresh(); |
| @@ -484,6 +491,7 @@ impl Chat { | |||
| 484 | builder_log_from: new_input(w().chat.date_from, window, cx), | 491 | builder_log_from: new_input(w().chat.date_from, window, cx), |
| 485 | builder_log_to: new_input(w().chat.date_to, window, cx), | 492 | builder_log_to: new_input(w().chat.date_to, window, cx), |
| 486 | builder_search, | 493 | builder_search, |
| 494 | + builder_friend_search, | ||
| 487 | builder_communities: vec![], | 495 | builder_communities: vec![], |
| 488 | pending_community_delete: None, | 496 | pending_community_delete: None, |
| 489 | builder_message_text: new_input(w().chat.text, window, cx), | 497 | builder_message_text: new_input(w().chat.text, window, cx), |