From f296e6e1cc4597474b04cb51ae0f108dae395366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 26 Nov 2026 03:17:28 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20aligned=20voice=20rows,?= =?UTF-8?q?=20strip/grid=20switch=20in=20header,=20viewer=20control=20bar,?= =?UTF-8?q?=20poll=20voters=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/camera_view.rs | 40 +-------- crates/client/src/gui/chat.rs | 83 ++++++++++++------ crates/client/src/gui/poll.rs | 120 ++++++++++++++++++++++++--- crates/client/src/gui/share_view.rs | 57 +++++-------- crates/client/src/gui/sidebar.rs | 115 +++++++++++++++---------- 5 files changed, 261 insertions(+), 154 deletions(-) diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 99580f3..786c68e 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -11,7 +11,7 @@ use gpui_kit::{ }; use super::{ - Palette, Tooltip as _, Yumush, avatar, clickable, entity_action, + Palette, Tooltip as _, Yumush, avatar, clickable, media_view::to_render_image, notify_error, share_view::{self, FRAME_TICK}, @@ -211,16 +211,7 @@ impl Yumush { .overflow_x_scroll() .border_b_1() .border_color(palette.border) - .children(tiles) - .child(icon_button( - "stage_grid", - palette, - IconName::LayoutDashboard, - "Grid", - entity_action(entity, |yumush, _, cx| { - yumush.set_stage(Stage::Grid, cx) - }), - )), + .children(tiles), ) } @@ -280,23 +271,7 @@ impl Yumush { .next() .unwrap_or_else(|| div().flex_1().into_any_element()) })) - })) - .child( - icon_button( - "stage_minimize", - palette, - IconName::Minimize, - "Strip", - entity_action(entity, |yumush, _, cx| { - yumush.set_stage(Stage::Strip, cx) - }), - ) - .absolute() - .top(px(12.)) - .right(px(12.)) - .bg(palette.panel) - .occlude(), - ), + })), ) } } @@ -514,12 +489,3 @@ fn grid_cell( cell.into_any_element() } } - -pub(super) fn stage_toggle(yumush: &mut Yumush, cx: &mut Context) { - let next = if yumush.chat.stage == Stage::Hidden { - Stage::Strip - } else { - Stage::Hidden - }; - yumush.set_stage(next, cx); -} diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 7bb1bd3..bf3e926 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -6,7 +6,7 @@ use std::{ time::{Duration, Instant}, }; -use crate::gui::camera_view::{self, Stage, Tile}; +use crate::gui::camera_view::{Stage, Tile}; use crate::gui::social::InviteLookup; use crate::gui::voice_stats::{SAMPLE_HISTORY, StatsTab}; use crate::gui::wave::Waves; @@ -917,9 +917,15 @@ impl Chat { } else { self.messages .iter() + .chain(&self.pins) .flat_map(|message| { std::iter::once(message.user_id) .chain(message.reply.as_ref().map(|quote| quote.user_id)) + .chain(message.poll.iter().flat_map(|poll| { + poll.options + .iter() + .flat_map(|option| option.voter_ids.iter().copied()) + })) }) .collect() }; @@ -2460,8 +2466,7 @@ impl Yumush { if users.is_empty() { return None; } - let stage = self.stage_sources().len(); - let hidden = self.chat.stage == Stage::Hidden; + let current = self.chat.stage; Some( div() @@ -2488,32 +2493,33 @@ impl Yumush { ) })) .children( - self.in_stage_chat() - .then(|| { - clickable( - if hidden { - "stage_toggle_hidden" - } else { - "stage_toggle_shown" - }, - palette, - entity_action(entity, |yumush: &mut Yumush, _, cx| { - camera_view::stage_toggle(yumush, cx) - }), - ) - .tip(if hidden { "Show stage" } else { "Hide stage" }) + self.in_stage_chat().then(|| { + div() .ml(px(8.)) - .h(px(22.)) - .px(px(6.)) .flex() .items_center() - .gap(px(4.)) + .p(px(2.)) + .gap(px(2.)) .rounded(px(6.)) - .text_size(text(11.)) - .text_color(if hidden { palette.muted } else { palette.accent }) - .child(Icon::new(IconName::LayoutDashboard).w(px(14.)).h(px(14.))) - .child(stage.to_string()) - }), + .border_1() + .border_color(palette.border) + .child(stage_button( + entity, + palette, + Stage::Strip, + current == Stage::Strip, + IconName::GalleryHorizontal, + "Strip", + )) + .child(stage_button( + entity, + palette, + Stage::Grid, + current == Stage::Grid, + IconName::LayoutGrid, + "Grid", + )) + }), ), ) } @@ -3042,3 +3048,30 @@ fn hard_breaks(body: &str) -> String { .collect(); lines.join("\n") } + +fn stage_button( + entity: &Entity, + palette: Palette, + layout: Stage, + active: bool, + icon: IconName, + name: &'static str, +) -> impl IntoElement { + clickable( + format!("stage_{name}_{active}"), + palette, + entity_action(entity, move |yumush: &mut Yumush, _, cx| { + let next = if active { Stage::Hidden } else { layout }; + yumush.set_stage(next, cx) + }), + ) + .tip(if active { "Hide" } else { name }) + .size(px(22.)) + .flex() + .items_center() + .justify_center() + .rounded(px(4.)) + .when(active, |this| this.bg(palette.hover)) + .text_color(if active { palette.accent } else { palette.muted }) + .child(Icon::new(icon).w(px(14.)).h(px(14.))) +} diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index 7785db2..65eeadc 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -2,15 +2,16 @@ use common::model::Id; use common::call::{ClosePoll, MyVotes, Vote}; use common::model::{Message, Poll, Rank, User}; use gpui_kit::{ - Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, Styled, - Window, assets::IconName, component::Icon, div, prelude::FluentBuilder as _, px, relative, + Anchor, AnyElement, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, + ParentElement, StatefulInteractiveElement, Styled, Window, assets::IconName, component::Icon, component::popover::Popover, + div, prelude::FluentBuilder as _, px, relative, }; use super::{ - Palette, Tooltip as _, Yumush, avatar, + Palette, Trigger, Tooltip as _, Yumush, avatar, chat::Chat, - clickable, text, - widget::{icon_button, spawn_done}, + clickable, hoverable, pop_in, text, + widget::{icon_button, panel, spawn_done}, }; pub fn voter_count(poll: &Poll) -> usize { @@ -57,6 +58,100 @@ fn status_icon(id: String, icon: IconName, tip: &'static str, palette: Palette) .child(Icon::new(icon).w(px(12.)).h(px(12.))) } +fn voters_label(voters: usize) -> Div { + div() + .flex() + .items_center() + .gap(px(4.)) + .child(Icon::new(IconName::Users).w(px(12.)).h(px(12.))) + .child(format!("{voters}")) +} + +fn voters_popover(key: &str, poll: &Poll, entity: &Entity, palette: Palette) -> AnyElement { + let options = poll.options.clone(); + let list = format!("poll_voters_list_{key}"); + let open = entity.clone(); + Popover::new(format!("poll_voters_{key}")) + .anchor(Anchor::BottomLeft) + .appearance(false) + .trigger(Trigger::new(hoverable( + format!("poll_voters_trigger_{key}"), + voters_label(voter_count(poll)), + palette, + ))) + .content(move |_, _, cx| { + let yumush = open.read(cx); + let chat = &yumush.chat; + let rows = options + .iter() + .filter(|option| !option.voter_ids.is_empty()) + .map(|option| { + div() + .flex() + .flex_col() + .child( + div() + .h(px(26.)) + .flex() + .items_center() + .gap(px(8.)) + .text_size(text(11.)) + .text_color(palette.muted) + .child( + div() + .flex_1() + .min_w_0() + .truncate() + .child(option.text.clone()), + ) + .child( + div() + .flex_shrink_0() + .child(format!("{}", option.voter_ids.len())), + ), + ) + .children(option.voter_ids.iter().filter_map(|id| { + chat.author(*id).map(|user| { + div() + .h(px(26.)) + .flex() + .items_center() + .gap(px(8.)) + .text_size(text(12.)) + .child(avatar( + palette, + user, + px(18.), + text(8.), + &chat.avatars, + )) + .child( + div() + .flex_1() + .min_w_0() + .truncate() + .child(user.username.clone()), + ) + }) + })) + }); + pop_in( + list.clone(), + panel(palette) + .w(px(260.)) + .id(list.clone()) + .max_h(px(320.)) + .overflow_y_scroll() + .p(px(6.)) + .flex() + .flex_col() + .children(rows), + Anchor::BottomLeft, + ) + }) + .into_any_element() +} + pub fn poll_card( poll: &Poll, mode: PollMode, @@ -194,20 +289,19 @@ pub fn poll_card( ) }); + let voters_view = if poll.public { + voters_popover(&key, poll, entity, palette) + } else { + voters_label(voters).into_any_element() + }; + let footer = div() .flex() .items_center() .justify_between() .text_size(text(12.)) .text_color(palette.muted) - .child( - div() - .flex() - .items_center() - .gap(px(4.)) - .child(Icon::new(IconName::Users).w(px(12.)).h(px(12.))) - .child(format!("{voters}")), - ) + .child(voters_view) .children(close_id.map(|close_id| { let close_entity = entity.clone(); icon_button( diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index a6e61fa..33104cb 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -24,7 +24,6 @@ use super::{ notify_error, pop_in, settings_page::segmented, text, - wave::wave_slot, widget::{icon_button, spawn_warn}, }; use crate::{ @@ -452,6 +451,7 @@ impl Yumush { .relative() .occlude() .bg(gpui_kit::black()) + .group("viewer") .children( viewer .frame @@ -461,53 +461,36 @@ impl Yumush { .child( div() .absolute() - .left(px(10.)) - .top(px(10.)) - .px(px(8.)) - .py(px(4.)) - .flex() - .items_center() - .gap(px(6.)) - .rounded(px(6.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) - .occlude() - .text_size(text(12.)) - .child(Icon::new(kind_icon(viewer.kind)).w(px(14.)).h(px(14.))) - .child(name.to_string()), - ) - .child( - div() - .absolute() - .right(px(10.)) - .bottom(px(10.)) - .p(px(6.)) + .left_0() + .right_0() + .bottom_0() + .h(px(44.)) + .px(px(12.)) .flex() .items_center() .gap(px(8.)) - .rounded(px(8.)) - .border_1() - .border_color(palette.border) - .bg(palette.panel) + .bg(gpui_kit::black().opacity(0.55)) .occlude() + .opacity(0.) + .group_hover("viewer", |style| style.opacity(1.)) .text_size(text(12.)) - .children(audio.then(|| { - wave_slot(self.chat.waves.share(viewer.user_id), 14., palette.alert) - })) + .text_color(palette.text) + .child(Icon::new(kind_icon(viewer.kind)).w(px(14.)).h(px(14.))) + .child(name.to_string()) + .child(div().flex_1()) .children(audio.then(|| { Icon::new(IconName::Volume2) .w(px(14.)) .h(px(14.)) .text_color(palette.muted) })) - .children( - audio.then(|| { - div() - .w(px(100.)) - .child(Slider::new(&viewer.volume).bg(palette.muted)) - }), - ) + .children(audio.then(|| { + div().w(px(80.)).child( + Slider::new(&viewer.volume) + .bg(palette.accent) + .text_color(palette.text), + ) + })) .child(icon_button( format!("share_fullscreen_{}", viewer.fullscreen), palette, diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 64c315e..a9180a8 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -240,8 +240,13 @@ impl Yumush { let screen = self.chat.share_of(community_id, user.id, Kind::Screen).is_some(); let camera = self.chat.share_of(community_id, user.id, Kind::Camera).is_some(); + let user_id = user.id; + let watch_screen = entity.clone(); + let watch_camera = entity.clone(); + let sharing = self.chat.waves.share(user_id).is_some(); + let member = profile_popover( - format!("voice_member_{}", user.id), + format!("voice_member_{user_id}"), Anchor::BottomLeft, user, entity, @@ -249,11 +254,9 @@ impl Yumush { .flex() .items_center() .gap(px(6.)) - .px(px(4.)) - .py(px(2.)) - .rounded(px(6.)) + .flex_1() + .min_w_0() .cursor_pointer() - .hover(move |style| style.bg(palette.hover)) .child( avatar(palette, user, px(18.), text(9.), &self.chat.avatars) .border_2() @@ -271,45 +274,73 @@ impl Yumush { .text_size(text(12.)) .text_color(palette.text) .child(user.username.clone()), - ) - .when(camera, |row| { - row.child( - Icon::new(IconName::Video) - .w(px(12.)) - .h(px(12.)) - .text_color(palette.alert), - ) - }) - .child(wave_slot(self.chat.waves.voice(user.id), 12., palette.ok)), + ), ); - let user_id = user.id; - let watch = entity.clone(); - - div().flex().flex_col().child(member).when(screen, |column| { - column.child( - clickable(format!("voice_screen_{user_id}"), palette, move |window, cx| { - watch.update(cx, |yumush, cx| { - yumush.toggle_viewer(user_id, Kind::Screen, window, cx) - }); - }) - .tip("Watch") - .ml(px(28.)) - .px(px(4.)) - .py(px(2.)) - .flex() - .items_center() - .gap(px(6.)) - .rounded(px(6.)) - .child( - Icon::new(IconName::ScreenShare) - .w(px(12.)) - .h(px(12.)) - .text_color(palette.alert), - ) - .child(div().flex_1()) - .child(wave_slot(self.chat.waves.share(user_id), 12., palette.alert)), + + div() + .flex() + .items_center() + .gap(px(4.)) + .px(px(4.)) + .py(px(2.)) + .rounded(px(6.)) + .hover(move |style| style.bg(palette.hover)) + .child(div().flex_1().min_w_0().child(member)) + .child( + div() + .w(px(20.)) + .h(px(20.)) + .flex_shrink_0() + .when(screen, |slot| { + slot.child( + clickable(format!("voice_screen_{user_id}"), palette, move |window, cx| { + watch_screen.update(cx, |yumush, cx| { + yumush.toggle_viewer(user_id, Kind::Screen, window, cx) + }); + }) + .tip("Watch") + .size_full() + .flex() + .items_center() + .justify_center() + .rounded(px(4.)) + .child( + Icon::new(IconName::ScreenShare) + .w(px(12.)) + .h(px(12.)) + .text_color(if sharing { palette.ok } else { palette.alert }), + ), + ) + }), ) - }) + .child( + div() + .w(px(20.)) + .h(px(20.)) + .flex_shrink_0() + .when(camera, |slot| { + slot.child( + clickable(format!("voice_camera_{user_id}"), palette, move |window, cx| { + watch_camera.update(cx, |yumush, cx| { + yumush.toggle_viewer(user_id, Kind::Camera, window, cx) + }); + }) + .tip("Watch") + .size_full() + .flex() + .items_center() + .justify_center() + .rounded(px(4.)) + .child( + Icon::new(IconName::Video) + .w(px(12.)) + .h(px(12.)) + .text_color(palette.alert), + ), + ) + }), + ) + .child(wave_slot(self.chat.waves.voice(user_id), 12., palette.ok)) } fn voice_dot(&self, entity: &Entity, palette: Palette) -> Option {