diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index 25df1a8..12b7f09 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -1302,9 +1302,7 @@ impl Render for Yumush { .text_color(palette.text) .text_size(text(style::text::UI)) .track_focus(&self.focus) - .on_action( - cx.listener(|this, _: &FocusFind, window, cx| this.chat.focus_find(window, cx)), - ) + .on_action(cx.listener(|this, _: &FocusFind, window, cx| this.open_friends(window, cx))) .on_action(cx.listener(|this, _: &CloseSettings, window, cx| { if this.fullscreen { this.toggle_fullscreen(cx); diff --git a/crates/client/src/gui/builder/communities.rs b/crates/client/src/gui/builder/communities.rs index c1216eb..21b86c8 100644 --- a/crates/client/src/gui/builder/communities.rs +++ b/crates/client/src/gui/builder/communities.rs @@ -249,8 +249,7 @@ impl Yumush { ) { let community_id = community.id; if self.chat.joined(community_id) { - let direct = community.kind.is_direct(); - self.go_to_community(community_id, direct, window, cx); + self.go_to_community(community_id, window, cx); } else { self.open_builder_community(community, window, cx); } diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 8c627b9..3b0a41e 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -268,7 +268,7 @@ impl Yumush { voice_line(self.chat.waves.voice(user.id), voice, t), t, ) - .w(px(size::TALK)) + .w_full() }); div() .flex() diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index db7a01f..71bef73 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -24,7 +24,7 @@ use crate::gui::{ profile::profile_popover, rank_tag, share_view::Viewer, - sidebar::{SidebarTab, unread_badge}, + sidebar::unread_badge, snippet, voice_note::{self, VoiceNote}, widget::{ok_or_notify, search_text, spawn_done}, @@ -76,6 +76,7 @@ pub enum View { Settings, CommunitySettings, Builder, + Friends, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -143,7 +144,6 @@ pub struct Chat { pub(super) community_hits: Vec, pub(super) found: Option, pub(super) invite: InviteLookup, - pub(super) tab: SidebarTab, pub(super) sidebar_collapsed: bool, pub(super) composer: Composer, pub(super) drafts: HashMap, @@ -389,7 +389,6 @@ impl Chat { community_hits: vec![], found: None, invite: InviteLookup::Idle, - tab: SidebarTab::Communities, sidebar_collapsed: false, view: View::Chat, section: 0, @@ -550,12 +549,6 @@ impl Chat { } } - pub fn focus_find(&mut self, window: &mut Window, cx: &mut Context) { - self.tab = SidebarTab::Messages; - self.search_input - .update(cx, |input, cx| input.focus(window, cx)); - } - pub fn slow_seconds(&self) -> Option { let remaining = self.slowed_until?.saturating_sub(common::time::now_ms()); (remaining > 0).then(|| remaining.div_ceil(1000)) @@ -1296,7 +1289,10 @@ impl RenderOnce for MembersTrigger { .rounded(px(radius::MD)) .text_size(text(text::LABEL)) .text_color(palette.muted) - .child(format!("{} people", self.members.len())), + .child(match self.members.len() { + 1 => "1 person".to_string(), + count => format!("{count} people"), + }), palette, ) } @@ -1312,11 +1308,7 @@ impl Yumush { .flex_row() .size_full() .when(self.chat.view == View::Chat, |page| { - page.child(self.sidebar( - &entity, - &search_text(&self.chat.search_input, cx), - palette, - )) + page.child(self.sidebar(&entity, palette)) }) .child(self.main_panel(&entity, palette, cx)) .children(self.fullscreen_viewer(&entity, palette)) @@ -1337,6 +1329,11 @@ impl Yumush { .map(|panel| match self.chat.view { View::Settings => panel.child(self.settings_page(entity, palette, cx)), View::Builder => panel.child(self.builder_page(entity, palette, cx)), + View::Friends => panel.child(self.friends_page( + entity, + &search_text(&self.chat.search_input, cx), + palette, + )), View::CommunitySettings => { panel.child(self.community_settings_page(entity, palette, cx)) } @@ -1417,6 +1414,7 @@ impl Yumush { super::parts::Ink::Paper, palette.tokens, )) + .children(group.then(|| members_popover(entity, self, palette))) .child(div().flex_1()) .children( community @@ -1435,7 +1433,6 @@ impl Yumush { (community.is_some() && !self.chat.pins.is_empty()) .then(|| message_actions::pins_popover(&self.chat, entity, palette)), ) - .children(group.then(|| members_popover(entity, self, palette))) } fn message_area(&self, entity: &Entity, palette: Palette) -> impl IntoElement { diff --git a/crates/client/src/gui/dock.rs b/crates/client/src/gui/dock.rs index f1f5288..cf0f64c 100644 --- a/crates/client/src/gui/dock.rs +++ b/crates/client/src/gui/dock.rs @@ -46,7 +46,7 @@ impl Yumush { camera: self.network.share_source(Kind::Camera).is_some(), screen: self.network.share_source(Kind::Screen).is_some(), }; - let (go_id, direct) = (community.id, community.kind.is_direct()); + let go_id = community.id; let actions = CallActions { mute: Rc::new(entity_action(entity, |yumush, window, cx| { yumush.toggle_mute(window, cx) @@ -65,7 +65,7 @@ impl Yumush { cx.notify(); })), stats: Rc::new(entity_action(entity, move |yumush, window, cx| { - yumush.go_to_community(go_id, direct, window, cx); + yumush.go_to_community(go_id, window, cx); yumush.chat.stats_open = !yumush.chat.stats_open; cx.notify(); })), diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 60e97c8..e0c1dcd 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -29,24 +29,13 @@ use super::{ presence_avatar, profile::profile_popover, social::Relation, - style::{radius, size, space, stroke, text}, + style::{radius, size, space, text}, wave::mini_wave, widget::{bare_input, compact_frame, icon_button}, }; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SidebarTab { - Messages, - Communities, -} - impl Yumush { - pub(super) fn sidebar( - &self, - entity: &Entity, - query: &str, - palette: Palette, - ) -> impl IntoElement { + pub(super) fn sidebar(&self, entity: &Entity, palette: Palette) -> impl IntoElement { let collapsed = self.chat.sidebar_collapsed; let (from, to, id) = if collapsed { (size::SIDEBAR, size::ROW, "sidebar_collapsing") @@ -56,7 +45,7 @@ impl Yumush { let content = if collapsed { self.collapsed_sidebar(entity, palette).into_any_element() } else { - self.expanded_sidebar(entity, query, palette) + self.expanded_sidebar(entity, palette) }; div() @@ -94,43 +83,77 @@ impl Yumush { ) } - fn expanded_sidebar(&self, entity: &Entity, query: &str, palette: Palette) -> AnyElement { - let (top, list) = match self.chat.tab { - SidebarTab::Messages => ( - Some(input_box(&self.chat.search_input, palette)), - self.messages_list(entity, query, palette) - .into_any_element(), - ), - SidebarTab::Communities => ( - None, - self.communities_list(entity, palette).into_any_element(), - ), - }; + fn expanded_sidebar(&self, entity: &Entity, palette: Palette) -> AnyElement { + let friends_alert = + !self.chat.friends.incoming.is_empty() || !self.chat.invitations.is_empty(); div() .h_full() .w(px(size::SIDEBAR)) .flex() .flex_col() - .py(px(space::MD)) - .px(px(space::MD)) - .gap(px(space::LG)) + .py(px(space::LG)) + .px(px(space::LG)) + .gap(px(space::XL)) .child( div() + .h(px(size::CONTROL)) .flex() .items_center() - .gap(px(space::SM)) - .child(self.tab_bar(entity, palette)) + .gap(px(space::XXS)) + .child( + div() + .id("wordmark") + .flex_1() + .px(px(space::SM)) + .text_size(text(text::TITLE)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(palette.text) + .context_menu(new_community_menu(entity)) + .child("yumuß"), + ) + .child( + div() + .relative() + .child(icon_button( + "friends_button", + palette, + IconName::Users, + "Friends", + entity_action(entity, |yumush, window, cx| { + yumush.open_friends(window, cx) + }), + )) + .children(friends_alert.then(|| { + div() + .absolute() + .top(px(space::XS)) + .right(px(space::XS)) + .size(px(space::XS + space::XXS)) + .rounded_full() + .bg(palette.text) + })), + ) .child(self.collapse_button(entity, palette)), ) - .children(top) .child( div() .id("sidebar_list") .flex_1() .min_h_0() .overflow_y_scroll() - .child(list), + .flex() + .flex_col() + .gap(px(space::XL)) + .child(self.communities_list(entity, palette)) + .child( + div() + .flex() + .flex_col() + .gap(px(space::XXS)) + .child(self.notes_row(entity, palette)) + .children(self.direct_rows(entity, "", palette)), + ), ) .children(self.account_row(entity, palette)) .into_any_element() @@ -138,14 +161,14 @@ impl Yumush { fn voice_chip(&self, community_id: Id, palette: Palette) -> AnyElement { let ids = self.chat.voice_ids(community_id); - let wave = ids + let speaker = ids .iter() - .filter(|id| self.chat.waves.speaking.contains(id)) - .find_map(|id| self.chat.waves.voice(*id)); - let voice = if wave.is_some() { - super::parts::Voice::Live(palette.ok) - } else { - super::parts::Voice::Quiet + .find(|id| self.chat.waves.speaking.contains(id)) + .copied(); + let wave = speaker.and_then(|id| self.chat.waves.voice(id)); + let voice = match speaker { + Some(id) => super::parts::Voice::Live(palette.tokens.person(id)), + None => super::parts::Voice::Quiet, }; div() .id(format!("voice_chip_{community_id}")) @@ -320,18 +343,12 @@ impl Yumush { pub(super) fn go_to_community( &mut self, community_id: Id, - direct: bool, window: &mut Window, cx: &mut Context, ) { if self.chat.view == View::Chat && self.chat.is_selected(community_id) { return; } - self.chat.tab = if direct { - SidebarTab::Messages - } else { - SidebarTab::Communities - }; self.show_view(View::Chat, window, cx); self.select_community(community_id, window, cx); } @@ -360,66 +377,12 @@ impl Yumush { .into_any_element() } - fn tab_bar(&self, entity: &Entity, palette: Palette) -> impl IntoElement { - let requests = (self.chat.friends.incoming.len() + self.chat.invitations.len()) as u32; - let direct = self.chat.unread_direct(); - let tabs = [ - ( - SidebarTab::Communities, - "Communities", - self.chat.unread_groups(), - ), - ( - SidebarTab::Messages, - "Messages", - Unread { - messages: direct.messages + requests, - mentions: direct.mentions + requests, - ..direct - }, - ), - ]; - - div() - .flex_1() - .flex() - .items_center() - .gap(px(space::LG)) - .children(tabs.map(|(tab, label, alert)| { - let active = self.chat.tab == tab; - let item = clickable( - label, - palette, - entity_action(entity, move |yumush, window, cx| { - yumush.set_sidebar_tab(tab, window, cx) - }), - ) - .flex() - .flex_col() - .gap(px(space::XXS)) - .text_size(text(text::CAPTION)) - .text_color(if active { palette.text } else { palette.muted }) - .when(active, |item| item.font_weight(FontWeight::MEDIUM)) - .child( - div() - .flex() - .items_center() - .gap(px(space::XS)) - .child(label) - .children(unread_badge(palette, false, Some(&alert))), - ) - .children(active.then(|| div().h(px(stroke::LINE)).bg(palette.text))); - - match tab { - SidebarTab::Communities => item - .context_menu(new_community_menu(entity)) - .into_any_element(), - SidebarTab::Messages => item.into_any_element(), - } - })) - } - - fn messages_list(&self, entity: &Entity, query: &str, palette: Palette) -> Div { + pub(super) fn friends_page( + &self, + entity: &Entity, + query: &str, + palette: Palette, + ) -> impl IntoElement { let found = self .chat .found @@ -427,29 +390,49 @@ impl Yumush { .filter(|user| !self.is_listed(user.id)); div() + .flex_1() + .min_h_0() .flex() .flex_col() - .gap(px(space::LG)) - .child(self.notes_row(entity, palette)) - .children(found.map(|user| self.found_row(entity, user, palette))) - .children( - query - .is_empty() - .then(|| self.requests(entity, palette)) - .flatten(), - ) + .child(super::settings_page::header(entity, palette, "Friends")) .child( div() - .flex() - .flex_col() - .gap(px(space::XXS)) - .children(self.direct_rows(entity, query, palette)), + .id("friends_scroll") + .flex_1() + .min_h_0() + .overflow_y_scroll() + .child( + div() + .w_full() + .max_w(px(size::SIDEBAR + size::PAGE)) + .pl(px(size::SIDEBAR + space::XL)) + .pr(px(space::XL)) + .py(px(space::LG)) + .flex() + .flex_col() + .gap(px(space::XL)) + .child(input_box(&self.chat.search_input, palette)) + .children(found.map(|user| self.found_row(entity, user, palette))) + .children( + query + .is_empty() + .then(|| self.requests(entity, palette)) + .flatten(), + ) + .children(group( + "Friends", + palette, + self.friend_rows(entity, query, palette), + )), + ), ) - .children(group( - "Friends", - palette, - self.friend_rows(entity, query, palette), - )) + } + + pub(super) fn open_friends(&mut self, window: &mut Window, cx: &mut Context) { + self.show_view(View::Friends, window, cx); + self.chat + .search_input + .update(cx, |input, cx| input.focus(window, cx)); } fn notes_row(&self, entity: &Entity, palette: Palette) -> AnyElement { @@ -830,6 +813,13 @@ impl Yumush { named: bool, palette: Palette, ) -> impl IntoElement { + let speaking = self.chat.waves.speaking.contains(&user.id); + let own_wave = self.chat.waves.voice(user.id); + let own_voice = if speaking { + super::parts::Voice::Live(palette.tokens.person(user.id)) + } else { + super::parts::Voice::Quiet + }; profile_popover( "account_profile", Anchor::BottomLeft, @@ -844,26 +834,39 @@ impl Yumush { .gap(px(space::SM)) .px(px(space::SM)) .rounded(px(radius::MD)) - .child(presence_avatar( - avatar( - palette, - user, + .when(!named, |trigger| { + trigger.child(presence_avatar( + avatar( + palette, + user, + px(size::AVATAR), + text(text::CAPTION), + &self.chat.avatars, + ), + self.presence_of(user.id), px(size::AVATAR), - text(text::CAPTION), - &self.chat.avatars, - ), - self.presence_of(user.id), - px(size::AVATAR), - palette, - )) + palette, + )) + }) .when(named, |trigger| { - trigger.child( - div() - .flex_1() - .min_w_0() - .font_weight(FontWeight::MEDIUM) - .child(user.username.clone()), - ) + trigger + .child( + div() + .min_w_0() + .truncate() + .text_color(palette.muted) + .child(user.username.clone()), + ) + .child( + div() + .w(px(size::CONTROL + space::LG)) + .h(px(space::MD)) + .child(super::parts::voice_line( + own_wave, + own_voice, + palette.tokens, + )), + ) }), palette, ), @@ -871,16 +874,6 @@ impl Yumush { .when(named, |trigger| trigger.flex_1().min_w_0()) } - fn set_sidebar_tab(&mut self, tab: SidebarTab, window: &mut Window, cx: &mut Context) { - self.chat.tab = tab; - if tab == SidebarTab::Messages { - self.chat - .search_input - .update(cx, |input, cx| input.focus(window, cx)); - } - cx.notify(); - } - pub(super) fn open_community_settings( &mut self, community_id: Id, @@ -896,11 +889,10 @@ fn go_to_call( entity: &Entity, community: &Community, ) -> impl Fn(&mut Window, &mut App) + 'static { - let direct = community.kind.is_direct(); let go_id = community.id; entity_action(entity, move |yumush, window, cx| { - yumush.go_to_community(go_id, direct, window, cx) + yumush.go_to_community(go_id, window, cx) }) }