From 86d0fa0885dbfaf50522d29baaec97c239291b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 27 Nov 2026 19:11:23 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20settings,=20community=20set?= =?UTF-8?q?tings=20and=20builder=20as=20full=20pages=20with=20a=20left=20i?= =?UTF-8?q?ndex=20('=E2=80=B9=20Settings',=20selected=20brighter=20+=20med?= =?UTF-8?q?ium);=20bare=20device=20pickers=20and=20test=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/build.rs | 34 +- crates/client/src/avatar.rs | 2 - crates/client/src/gui.rs | 36 +- crates/client/src/gui/builder.rs | 62 +-- crates/client/src/gui/builder/communities.rs | 4 +- crates/client/src/gui/builder/log.rs | 10 +- crates/client/src/gui/builder/messages.rs | 15 +- crates/client/src/gui/builder/overview.rs | 19 +- crates/client/src/gui/builder/storage.rs | 31 +- crates/client/src/gui/builder/ui.rs | 8 +- crates/client/src/gui/builder/users.rs | 10 +- crates/client/src/gui/builder/voice.rs | 3 +- crates/client/src/gui/call_bar.rs | 61 ++- crates/client/src/gui/camera_view.rs | 19 +- crates/client/src/gui/chat.rs | 385 ++++++++++--------- crates/client/src/gui/community_settings.rs | 103 ++--- crates/client/src/gui/composer.rs | 7 +- crates/client/src/gui/forward.rs | 12 +- crates/client/src/gui/gallery.rs | 161 ++++++-- crates/client/src/gui/message_actions.rs | 13 +- crates/client/src/gui/parts.rs | 89 ++++- crates/client/src/gui/poll.rs | 25 +- crates/client/src/gui/profile.rs | 24 +- crates/client/src/gui/settings_page.rs | 344 +++++++++-------- crates/client/src/gui/share_view.rs | 26 +- crates/client/src/gui/sidebar.rs | 28 +- crates/client/src/gui/snippet.rs | 8 +- crates/client/src/gui/social.rs | 3 +- crates/client/src/gui/style.rs | 16 +- crates/client/src/gui/voice_settings.rs | 21 +- crates/client/src/gui/voice_stats.rs | 37 +- 31 files changed, 1024 insertions(+), 592 deletions(-) diff --git a/crates/client/build.rs b/crates/client/build.rs index e0bd290..ea13a8a 100644 --- a/crates/client/build.rs +++ b/crates/client/build.rs @@ -17,13 +17,22 @@ fn main() { let mut out = String::new(); let hues = names(&tokens["hues"]); - writeln!(out, "pub const HUE_NAMES: [&str; {}] = {hues:?};", hues.len()).unwrap(); + writeln!( + out, + "pub const HUE_NAMES: [&str; {}] = {hues:?};", + hues.len() + ) + .unwrap(); let themes = tokens["theme"].as_table().expect("theme table"); writeln!( out, "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\npub enum Theme {{ {} }}", - themes.keys().map(|name| camel(name)).collect::>().join(", ") + themes + .keys() + .map(|name| camel(name)) + .collect::>() + .join(", ") ) .unwrap(); writeln!( @@ -39,7 +48,9 @@ fn main() { writeln!( out, "pub struct Colors {{\n pub dark: bool,\n{} pub hue: [u32; {}],\n}}", - COLORS.map(|name| format!(" pub {name}: u32,\n")).concat(), + COLORS + .map(|name| format!(" pub {name}: u32,\n")) + .concat(), hues.len() ) .unwrap(); @@ -53,9 +64,15 @@ fn main() { name.to_uppercase(), theme["dark"].as_bool().expect("dark"), COLORS - .map(|color| format!(" {color}: {},\n", hex(theme[color].as_str().expect(color)))) + .map(|color| format!( + " {color}: {},\n", + hex(theme[color].as_str().expect(color)) + )) .concat(), - hue.iter().map(|color| hex(color)).collect::>().join(", ") + hue.iter() + .map(|color| hex(color)) + .collect::>() + .join(", ") ) .unwrap(); } @@ -68,7 +85,12 @@ fn main() { Value::Float(value) => *value as f32, _ => panic!("{scale}.{name} is not a number"), }; - writeln!(out, " pub const {}: f32 = {value:?};", name.to_uppercase()).unwrap(); + writeln!( + out, + " pub const {}: f32 = {value:?};", + name.to_uppercase() + ) + .unwrap(); } writeln!(out, "}}").unwrap(); } diff --git a/crates/client/src/avatar.rs b/crates/client/src/avatar.rs index 54366c6..95a20e8 100644 --- a/crates/client/src/avatar.rs +++ b/crates/client/src/avatar.rs @@ -52,5 +52,3 @@ fn encode(image: &RgbImage, quality: u8) -> Result, Fail> { fn image_error(error: image::ImageError) -> Fail { Fail::Io(error.to_string()) } - - diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index 61e0fa6..25df1a8 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -1,10 +1,5 @@ use common::model::{Hue, Id}; -use std::{ - collections::HashMap, - fmt::Display, - sync::Arc, - time::Instant, -}; +use std::{collections::HashMap, fmt::Display, sync::Arc, time::Instant}; use common::{ call::{GetAvatar, GetSettings, MarkRead}, @@ -17,11 +12,10 @@ use common::{ }, }; use gpui_kit::{ - AnyElement, AnyWindowHandle, App, - AppContext, AsyncWindowContext, Context, Div, ElementId, Entity, FontWeight, Hsla, Image, - ImageFormat, InteractiveElement, IntoElement, KeyBinding, KeyDownEvent, KeyUpEvent, - ModifiersChangedEvent, ParentElement, Pixels, Rems, Render, RenderOnce, Stateful, - StatefulInteractiveElement, Styled, WeakEntity, Window, actions, + AnyElement, AnyWindowHandle, App, AppContext, AsyncWindowContext, Context, Div, ElementId, + Entity, FontWeight, Hsla, Image, ImageFormat, InteractiveElement, IntoElement, KeyBinding, + KeyDownEvent, KeyUpEvent, ModifiersChangedEvent, ParentElement, Pixels, Rems, Render, + RenderOnce, Stateful, StatefulInteractiveElement, Styled, WeakEntity, Window, actions, base::Selectable, component::{ Sizable, Theme, ThemeRegistry, WindowExt, @@ -42,19 +36,18 @@ use crate::{ }; mod auth; -mod call_bar; -pub mod gallery; -mod parts; -pub mod style; mod builder; +mod call_bar; mod camera_view; mod chat; mod community_settings; mod composer; mod dock; mod forward; +pub mod gallery; mod media_view; mod message_actions; +mod parts; mod poll; mod profile; mod settings_page; @@ -63,6 +56,7 @@ mod sidebar; mod snippet; mod social; mod stream_stats; +pub mod style; mod surface; mod voice_note; mod voice_settings; @@ -71,8 +65,8 @@ mod wave; mod widget; use auth::Auth; -use style::{Tokens, radius, size, space}; use chat::{Chat, View}; +use style::{Tokens, radius, size, space}; use voice_settings::VoiceControls; actions!(yumush, [FocusFind, CloseSettings]); @@ -202,7 +196,6 @@ pub fn sync_theme(cx: &mut App) { const FIND_KEY: &str = "ctrl-k"; pub const FIND_HINT: &str = "Ctrl K"; - pub fn badge(palette: Palette, id: Id, name: &str, size: Pixels, font: Rems) -> Div { let initial = name .chars() @@ -267,10 +260,14 @@ pub fn community_icon( .rounded(px(radius::SM)) .overflow_hidden() .child(img(image.clone()).size_full()), - None => badge(palette, community.id, &community.name, size, font).rounded(px(radius::SM)), + None => { + badge(palette, community.id, &community.name, size, font).rounded(px(radius::SM)) + } }, CommunityKind::Direct { peer } => avatar(palette, peer, size, font, avatars), - CommunityKind::Notes => badge(palette, community.id, "Notes", size, font).rounded(px(radius::SM)), + CommunityKind::Notes => { + badge(palette, community.id, "Notes", size, font).rounded(px(radius::SM)) + } } } @@ -757,6 +754,7 @@ impl Yumush { } fn show_view(&mut self, view: View, window: &mut Window, cx: &mut Context) { + self.chat.section = 0; if self.chat.view == View::Settings && view != View::Settings { self.leave_settings(); } diff --git a/crates/client/src/gui/builder.rs b/crates/client/src/gui/builder.rs index 75d362c..575769f 100644 --- a/crates/client/src/gui/builder.rs +++ b/crates/client/src/gui/builder.rs @@ -20,20 +20,20 @@ use common::{ permission, }; use gpui_kit::{ - AnyElement, App, Context, Div, Entity, InteractiveElement, IntoElement, ParentElement, - StatefulInteractiveElement, Styled, Window, - assets::IconName, - component::{Icon, input::InputState}, - div, - prelude::FluentBuilder as _, - px, + AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, + ParentElement, StatefulInteractiveElement, Styled, Window, assets::IconName, + component::input::InputState, div, prelude::FluentBuilder as _, px, }; use self::ui::{accent_button, icon_button, page_heading, plain_button}; use super::{ - Palette, Yumush, chat::View, clickable, entity_action, notify_error, settings_page::header, - style::{radius, size, space, text}, - text, widget::search_text, + Palette, Yumush, + chat::View, + clickable, entity_action, notify_error, + settings_page::header, + style::{size, space, text}, + text, + widget::search_text, }; use crate::net::NetworkHandle; @@ -83,21 +83,6 @@ impl BuilderTab { Self::Log => "Log", } } - - fn icon(self) -> IconName { - match self { - Self::Overview => IconName::LayoutDashboard, - Self::Users => IconName::Users, - Self::Communities => IconName::Building2, - Self::Messages => IconName::MessageSquare, - Self::Voice => IconName::Mic, - Self::Storage => IconName::HardDrive, - Self::Access => IconName::Key, - Self::Reports => IconName::Flag, - Self::Server => IconName::Server, - Self::Log => IconName::ScrollText, - } - } } pub(super) struct Transfer { @@ -225,10 +210,8 @@ impl Yumush { .flex() .flex_col() .gap(px(space::XXS)) - .p(px(space::SM)) - .bg(palette.panel) - .border_r_1() - .border_color(palette.border) + .px(px(space::XL)) + .py(px(space::LG)) .children(BuilderTab::ALL.map(|tab| self.builder_nav_item(tab, entity, palette))) .child(div().flex_1()) .child(self.ghost_toggle(entity, palette)) @@ -241,7 +224,6 @@ impl Yumush { palette: Palette, ) -> impl IntoElement { let label = tab.label(); - let icon = tab.icon(); let active = self.chat.builder_tab == tab; let color = if active { palette.text } else { palette.muted }; let open = (tab == BuilderTab::Reports) @@ -256,23 +238,16 @@ impl Yumush { }), ) .h(px(size::CONTROL)) - .px(px(space::MD)) .flex() .items_center() .gap(px(space::SM)) - .rounded(px(radius::MD)) - .text_size(text(text::LABEL)) .text_color(color) - .when(active, |this| this.bg(palette.hover)) - .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color)) + .when(active, |this| this.font_weight(FontWeight::MEDIUM)) .child(div().flex_1().min_w_0().truncate().child(label)) .children(open.map(|count| { div() - .px(px(space::XS)) - .rounded_full() - .bg(palette.accent) - .text_color(palette.on_accent) .text_size(text(text::CAPTION)) + .text_color(palette.text) .child(count.to_string()) })) } @@ -292,9 +267,12 @@ impl Yumush { .text_size(text(text::LABEL)) .text_color(palette.muted) .child("Ghost") - .child( - super::parts::toggle("ghost_switch", enabled, palette.tokens, toggle), - ) + .child(super::parts::toggle( + "ghost_switch", + enabled, + palette.tokens, + toggle, + )) } pub(super) fn is_builder(&self) -> bool { diff --git a/crates/client/src/gui/builder/communities.rs b/crates/client/src/gui/builder/communities.rs index 56f25f7..c1216eb 100644 --- a/crates/client/src/gui/builder/communities.rs +++ b/crates/client/src/gui/builder/communities.rs @@ -16,7 +16,9 @@ use super::{ ui::{card, confirmed, icon_button, pill, plain_button, rows_body}, }; use crate::gui::{ - Palette, Yumush, avatar, chat::View, community_icon, entity_action, notify_error, + Palette, Yumush, avatar, + chat::View, + community_icon, entity_action, notify_error, profile::user_link, style::{radius, size, space, text}, text, diff --git a/crates/client/src/gui/builder/log.rs b/crates/client/src/gui/builder/log.rs index 81564a4..bd1e4e2 100644 --- a/crates/client/src/gui/builder/log.rs +++ b/crates/client/src/gui/builder/log.rs @@ -284,11 +284,11 @@ impl Yumush { pub(super) fn log_body(&self, entity: &Entity, palette: Palette) -> Vec { let filters = toolbar(vec![ - fixed(size::THUMB,field(palette, &self.chat.builder_log_actor)), - fixed(size::THUMB,field(palette, &self.chat.builder_log_target)), - fixed(size::THUMB,Select::new(&self.chat.builder_log_action)), - fixed(size::THUMB,field(palette, &self.chat.builder_log_from)), - fixed(size::THUMB,field(palette, &self.chat.builder_log_to)), + fixed(size::THUMB, field(palette, &self.chat.builder_log_actor)), + fixed(size::THUMB, field(palette, &self.chat.builder_log_target)), + fixed(size::THUMB, Select::new(&self.chat.builder_log_action)), + fixed(size::THUMB, field(palette, &self.chat.builder_log_from)), + fixed(size::THUMB, field(palette, &self.chat.builder_log_to)), accent_button( "apply_builder_log", "Apply", diff --git a/crates/client/src/gui/builder/messages.rs b/crates/client/src/gui/builder/messages.rs index f8dffdc..5207f0d 100644 --- a/crates/client/src/gui/builder/messages.rs +++ b/crates/client/src/gui/builder/messages.rs @@ -172,7 +172,12 @@ impl Yumush { &self.chat.builder_message_from, &self.chat.builder_message_to, ] - .map(|input| div().flex_1().min_w(px(size::THUMB)).child(field(palette, input))), + .map(|input| { + div() + .flex_1() + .min_w(px(size::THUMB)) + .child(field(palette, input)) + }), ) .child(accent_button( "search_messages", @@ -194,7 +199,13 @@ impl Yumush { .as_ref() .is_some_and(|author| self.chat.pending_builder_purge == Some(author.id)); let picture = match &hit.author { - Some(author) => avatar(palette, author, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), + Some(author) => avatar( + palette, + author, + px(size::AVATAR), + text(text::CAPTION), + &self.chat.avatars, + ), None => div() .size(px(size::AVATAR)) .flex_shrink_0() diff --git a/crates/client/src/gui/builder/overview.rs b/crates/client/src/gui/builder/overview.rs index f136c61..9bb0e9e 100644 --- a/crates/client/src/gui/builder/overview.rs +++ b/crates/client/src/gui/builder/overview.rs @@ -24,11 +24,14 @@ fn day_label(day: u64) -> String { } fn tile_row(tiles: &[(&str, String)], palette: Palette) -> Div { - div().flex().gap(px(space::MD)).children( - tiles - .iter() - .map(|(label, value)| stat_tile(label, value, palette).flex_1().min_w(px(size::SIDEBAR))), - ) + div() + .flex() + .gap(px(space::MD)) + .children(tiles.iter().map(|(label, value)| { + stat_tile(label, value, palette) + .flex_1() + .min_w(px(size::SIDEBAR)) + })) } fn bar_chart( @@ -93,7 +96,11 @@ fn bar_chart( ) }; - div().flex_1().h(px(height)).rounded_t(px(radius::SM)).bg(color) + div() + .flex_1() + .h(px(height)) + .rounded_t(px(radius::SM)) + .bg(color) })), ) .child( diff --git a/crates/client/src/gui/builder/storage.rs b/crates/client/src/gui/builder/storage.rs index a0a1858..931c2a2 100644 --- a/crates/client/src/gui/builder/storage.rs +++ b/crates/client/src/gui/builder/storage.rs @@ -17,10 +17,12 @@ use super::ui::{ toolbar, }; use crate::gui::{ - DATE, Palette, Yumush, community_settings::user_name, entity_action, millis_time, notify_error, - storage, + DATE, Palette, Yumush, + community_settings::user_name, + entity_action, millis_time, notify_error, storage, style::{radius, size, space, text}, - text, widget::field, + text, + widget::field, }; fn share(bytes: u64, max: u64) -> f32 { @@ -72,13 +74,17 @@ fn usage_row(name: &str, bytes: u64, count: u64, fraction: f32, palette: Palette ), ) .child( - div().h(px(space::XXS)).rounded(px(radius::SM)).bg(palette.hover).child( - div() - .h_full() - .w(relative(fraction)) - .rounded(px(radius::SM)) - .bg(palette.accent), - ), + div() + .h(px(space::XXS)) + .rounded(px(radius::SM)) + .bg(palette.hover) + .child( + div() + .h_full() + .w(relative(fraction)) + .rounded(px(radius::SM)) + .bg(palette.accent), + ), ) } @@ -201,7 +207,10 @@ impl Yumush { )); let controls = toolbar(vec![ - fixed(size::THUMB, field(palette, &self.chat.builder_attachment_user)), + fixed( + size::THUMB, + field(palette, &self.chat.builder_attachment_user), + ), fixed( size::THUMB, field(palette, &self.chat.builder_attachment_community), diff --git a/crates/client/src/gui/builder/ui.rs b/crates/client/src/gui/builder/ui.rs index 54753bc..6a0142d 100644 --- a/crates/client/src/gui/builder/ui.rs +++ b/crates/client/src/gui/builder/ui.rs @@ -152,7 +152,13 @@ pub(super) fn action_group( .flex() .flex_col() .gap(px(space::XS)) - .child(div().flex().flex_wrap().gap(px(space::XS)).children(children)), + .child( + div() + .flex() + .flex_wrap() + .gap(px(space::XS)) + .children(children), + ), ), ) } diff --git a/crates/client/src/gui/builder/users.rs b/crates/client/src/gui/builder/users.rs index 12f0da8..54abd48 100644 --- a/crates/client/src/gui/builder/users.rs +++ b/crates/client/src/gui/builder/users.rs @@ -27,8 +27,8 @@ use crate::{ DATE, DAY, Palette, Tooltip as _, Yumush, avatar, clickable, entity_action, millis_time, notify_error, profile::user_link, - text, style::{radius, size, space, text}, + text, widget::{field, search_text}, }, net::{Fail, NetworkHandle}, @@ -866,7 +866,13 @@ impl Yumush { format!("builder_user_avatar_{}", user.id), Some(user), entity, - avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), + avatar( + palette, + user, + px(size::AVATAR), + text(text::CAPTION), + &self.chat.avatars, + ), )) .child( div() diff --git a/crates/client/src/gui/builder/voice.rs b/crates/client/src/gui/builder/voice.rs index 6ca701b..cb34f8c 100644 --- a/crates/client/src/gui/builder/voice.rs +++ b/crates/client/src/gui/builder/voice.rs @@ -13,7 +13,8 @@ use gpui_kit::{ use super::ui::{card, card_header, icon_button, list_card, pill, rows_body}; use crate::{ gui::{ - Palette, Yumush, avatar, entity_action, notify_error, profile::user_link, + Palette, Yumush, avatar, entity_action, notify_error, + profile::user_link, style::{self, size, space}, text, }, diff --git a/crates/client/src/gui/call_bar.rs b/crates/client/src/gui/call_bar.rs index d35e41b..e15d5e9 100644 --- a/crates/client/src/gui/call_bar.rs +++ b/crates/client/src/gui/call_bar.rs @@ -1,8 +1,8 @@ use std::{collections::VecDeque, rc::Rc}; use gpui_kit::{ - AnyElement, App, Div, FontWeight, InteractiveElement, ParentElement, - SharedString, StatefulInteractiveElement, Styled, Window, assets::IconName, div, px, + AnyElement, App, Div, FontWeight, InteractiveElement, ParentElement, SharedString, + StatefulInteractiveElement, Styled, Window, assets::IconName, div, px, }; use super::{ @@ -43,14 +43,24 @@ fn run(action: &Action) -> impl Fn(&mut Window, &mut App) + 'static { pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { let tone = |on: bool| if on { Tone::On } else { Tone::Idle }; let alarm = |on: bool| if on { Tone::Danger } else { Tone::Idle }; - let ping_ink = if bar.voice == Voice::Frayed { Ink::Bad } else { Ink::Faint }; - let ping = bar.ping.map_or_else(|| "–".to_string(), |ping| format!("{ping:.0} ms")); + let ping_ink = if bar.voice == Voice::Frayed { + Ink::Bad + } else { + Ink::Faint + }; + let ping = bar + .ping + .map_or_else(|| "–".to_string(), |ping| format!("{ping:.0} ms")); let stats = run(&actions.stats); let controls = band(space::XS) .flex_none() .child(icon_button( format!("bar_mute_{}", bar.muted), - if bar.muted { IconName::MicOff } else { IconName::Mic }, + if bar.muted { + IconName::MicOff + } else { + IconName::Mic + }, if bar.muted { "Unmute" } else { "Mute" }, alarm(bar.muted), t, @@ -58,7 +68,11 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { )) .child(icon_button( format!("bar_deafen_{}", bar.deafened), - if bar.deafened { IconName::HeadphoneOff } else { IconName::Headphones }, + if bar.deafened { + IconName::HeadphoneOff + } else { + IconName::Headphones + }, if bar.deafened { "Undeafen" } else { "Deafen" }, alarm(bar.deafened), t, @@ -67,7 +81,11 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { .child(icon_button( format!("bar_camera_{}", bar.camera), IconName::Video, - if bar.camera { "Turn off camera" } else { "Turn on camera" }, + if bar.camera { + "Turn off camera" + } else { + "Turn on camera" + }, tone(bar.camera), t, run(&actions.camera), @@ -76,19 +94,40 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { .child(icon_button( format!("bar_screen_{}", bar.screen), IconName::ScreenShare, - if bar.screen { "Stop sharing" } else { "Share screen" }, + if bar.screen { + "Stop sharing" + } else { + "Share screen" + }, tone(bar.screen), t, run(&actions.screen), )) .child(actions.screen_more) - .child(icon_button("bar_leave", IconName::PhoneOff, "Leave call", Tone::Danger, t, run(&actions.leave))); + .child(icon_button( + "bar_leave", + IconName::PhoneOff, + "Leave call", + Tone::Danger, + t, + run(&actions.leave), + )); div().flex_none().child(thread(t)).child( band(space::LG) .h(px(size::ROW + space::MD)) .px(px(space::LG)) - .child(words(bar.name, Text::Ui, Ink::Paper, t).font_weight(FontWeight::MEDIUM).flex_none()) - .child(div().flex_1().min_w(px(size::CONTROL)).h(px(size::ICON)).child(voice_line(bar.bands.as_ref(), bar.voice, t))) + .child( + words(bar.name, Text::Ui, Ink::Paper, t) + .font_weight(FontWeight::MEDIUM) + .flex_none(), + ) + .child( + div() + .flex_1() + .min_w(px(size::CONTROL)) + .h(px(size::ICON)) + .child(voice_line(bar.bands.as_ref(), bar.voice, t)), + ) .child( div() .id("bar_ping") diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 93cf56c..8c627b9 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -10,11 +10,16 @@ use gpui_kit::{ }; use super::{ - Palette, Tooltip as _, Yumush, avatar, clickable, media_view::into_render_image, notify_error, + Palette, Tooltip as _, Yumush, avatar, clickable, + media_view::into_render_image, + notify_error, + parts::{Voice, caption, voice_line}, share_view, style::{radius, size, space, text}, - parts::{Voice, caption, voice_line}, - surface::Surface, text, wave::mini_wave, widget::spawn_warn, + surface::Surface, + text, + wave::mini_wave, + widget::spawn_warn, }; use crate::share::session::WatchQuality; @@ -258,8 +263,12 @@ impl Yumush { } else { Voice::Quiet }; - caption(user.username.clone(), voice_line(self.chat.waves.voice(user.id), voice, t), t) - .w(px(size::TALK)) + caption( + user.username.clone(), + voice_line(self.chat.waves.voice(user.id), voice, t), + t, + ) + .w(px(size::TALK)) }); div() .flex() diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 7fcbee7..db7a01f 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -160,6 +160,7 @@ pub struct Chat { pub(super) jump: Option, highlight: Option<(Id, Instant)>, pub(super) view: View, + pub(super) section: usize, pub(super) username_input: Entity, pub(super) community_name_input: Entity, pub(super) status_input: Entity, @@ -391,6 +392,7 @@ impl Chat { tab: SidebarTab::Communities, sidebar_collapsed: false, view: View::Chat, + section: 0, username_input: editable_input("Username...", Yumush::save_username, window, cx), community_name_input: editable_input( "Community name...", @@ -1309,7 +1311,13 @@ impl Yumush { .flex() .flex_row() .size_full() - .child(self.sidebar(&entity, &search_text(&self.chat.search_input, cx), palette)) + .when(self.chat.view == View::Chat, |page| { + page.child(self.sidebar( + &entity, + &search_text(&self.chat.search_input, cx), + palette, + )) + }) .child(self.main_panel(&entity, palette, cx)) .children(self.fullscreen_viewer(&entity, palette)) } @@ -1403,7 +1411,12 @@ impl Yumush { .flex() .items_center() .gap(px(space::SM)) - .child(super::parts::words(name.to_string(), super::parts::Text::Title, super::parts::Ink::Paper, palette.tokens)) + .child(super::parts::words( + name.to_string(), + super::parts::Text::Title, + super::parts::Ink::Paper, + palette.tokens, + )) .child(div().flex_1()) .children( community @@ -1621,51 +1634,54 @@ impl Yumush { .border_t_1() .border_color(palette.border), ) - .children(pending) - .children(bar) - .children(self.chat.typing_label().map(|label| { - div() - .pl(px(space::XS)) - .pb(px(space::XS)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(label) - })) - .child( - div() - .min_h(px(size::ROW)) - .pl(px(space::XS)) - .pr(px(space::XS)) - .py(px(space::XS)) + .children(pending) + .children(bar) + .children(self.chat.typing_label().map(|label| { + div() + .pl(px(space::XS)) + .pb(px(space::XS)) + .text_size(text(text::CAPTION)) + .text_color(palette.muted) + .child(label) + })) + .child( + div() + .min_h(px(size::ROW)) + .pl(px(space::XS)) + .pr(px(space::XS)) + .py(px(space::XS)) + .flex() + .items_center() + .gap(px(space::SM)) + .child(composer::plus_popover(&self.chat, &entity, palette)) + .child(composer::format_popover(palette)) + .child( + Textarea::new(&self.chat.message_input) + .appearance(false) + .text_size(text(text::BODY)) + .text_color(palette.text) + .flex_1() + .min_w_0(), + ) + .child(voice_note::mic_button(&entity, palette)) + .child( + clickable("send_button", palette, move |window, cx| { + entity.update(cx, |yumush, cx| yumush.submit_composer(&input, window, cx)) + }) + .tip("Send") + .size(px(size::CONTROL_SM)) .flex() .items_center() - .gap(px(space::SM)) - .child(composer::plus_popover(&self.chat, &entity, palette)) - .child(composer::format_popover(palette)) - .child( - Textarea::new(&self.chat.message_input) - .appearance(false) - .text_size(text(text::BODY)) - .text_color(palette.text) - .flex_1() - .min_w_0(), - ) - .child(voice_note::mic_button(&entity, palette)) - .child( - clickable("send_button", palette, move |window, cx| { - entity - .update(cx, |yumush, cx| yumush.submit_composer(&input, window, cx)) - }) - .tip("Send") - .size(px(size::CONTROL_SM)) - .flex() - .items_center() - .justify_center() - .text_color(if has_text { palette.text } else { palette.muted }) - .child(Icon::new(IconName::ArrowUp).size(px(size::ICON_SM))), - ), - ) - .into_any_element() + .justify_center() + .text_color(if has_text { + palette.text + } else { + palette.muted + }) + .child(Icon::new(IconName::ArrowUp).size(px(size::ICON_SM))), + ), + ) + .into_any_element() } pub(super) fn select_community( @@ -2400,7 +2416,11 @@ impl Yumush { (false, true) => (IconName::Headphones, "Leave voice"), }; let id = format!("voice_button_{direct}_{in_voice}"); - let color = if in_voice { palette.danger } else { palette.muted }; + let color = if in_voice { + palette.danger + } else { + palette.muted + }; Some( clickable(id, palette, on_click) @@ -2677,7 +2697,13 @@ fn members_popover(entity: &Entity, yumush: &Yumush, palette: Palette) - .gap(px(space::SM)) .rounded(px(radius::MD)) .child(presence_avatar( - avatar(palette, user, px(size::ICON), text(text::CAPTION), &avatars), + avatar( + palette, + user, + px(size::ICON), + text(text::CAPTION), + &avatars, + ), *presence, px(size::ICON), palette, @@ -2847,20 +2873,16 @@ fn render_message( } let author = chat.author(message.user_id); let username = author.map_or("unknown", |user| user.username.as_str()); - let name = div() - .flex() - .items_center() - .gap(px(space::SM)) - .child( - div() - .id(format!("author_name_{}", message.id)) - .font_weight(FontWeight::SEMIBOLD) - .text_color(palette.text) - .when(author.is_some(), |this| { - this.hover(|style| style.underline()) - }) - .child(username.to_string()), - ); + let name = div().flex().items_center().gap(px(space::SM)).child( + div() + .id(format!("author_name_{}", message.id)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(palette.text) + .when(author.is_some(), |this| { + this.hover(|style| style.underline()) + }) + .child(username.to_string()), + ); let mentioned = me.is_some_and(|me| mentions(&message.body, &me.username)); let mine = me.is_some_and(|me| me.id == message.user_id); let group = format!("message_{}", message.id); @@ -2871,140 +2893,137 @@ fn render_message( .as_ref() .is_some_and(|(id, at)| id == &message.id && at.elapsed() < HIGHLIGHT_TTL); - let row = div() - .id(format!("message_row_{}", message.id)) - .group(group.clone()) - .relative() - .flex() - .flex_col() - .min_w_0() - .hover(|style| style.bg(palette.hover)) - .when(first && spaced && !selecting, |this| this.mt(px(space::LG))) - .when(highlighted, |this| this.bg(palette.tokens.press())) - .when(mentioned, |this| { - this.border_l_2() - .border_color(palette.accent) - }) - .when(first, |this| { - let author = match author { - Some(user) => profile_popover( - format!("author_{}", message.id), - Anchor::TopLeft, - user, - entity, - name.cursor_pointer(), - ) - .into_any_element(), - None => name.into_any_element(), - }; + let row = + div() + .id(format!("message_row_{}", message.id)) + .group(group.clone()) + .relative() + .flex() + .flex_col() + .min_w_0() + .hover(|style| style.bg(palette.hover)) + .when(first && spaced && !selecting, |this| this.mt(px(space::LG))) + .when(highlighted, |this| this.bg(palette.tokens.press())) + .when(mentioned, |this| { + this.border_l_2().border_color(palette.accent) + }) + .when(first, |this| { + let author = match author { + Some(user) => profile_popover( + format!("author_{}", message.id), + Anchor::TopLeft, + user, + entity, + name.cursor_pointer(), + ) + .into_any_element(), + None => name.into_any_element(), + }; - this.child( + this.child( + div() + .relative() + .flex() + .items_center() + .gap(px(space::SM)) + .mb(px(space::XXS)) + .child(thread_dot(mine, palette)) + .child(author) + .child( + div() + .text_size(text(text::CAPTION)) + .text_color(palette.muted) + .child(millis_time(message.created_at, CLOCK)), + ), + ) + }) + .child( div() .relative() + .min_w_0() .flex() .items_center() .gap(px(space::SM)) - .mb(px(space::XXS)) - .child(thread_dot(mine, palette)) - .child(author) .child( div() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(millis_time(message.created_at, CLOCK)), - ), - ) - }) - .child( - div() - .relative() - .min_w_0() - .flex() - .items_center() - .gap(px(space::SM)) - .child( - div() - .min_w_0() - .max_w(px(size::PAGE)) - .when(message.body.contains("```"), |this| this.w_full()) - .flex() - .flex_col() - .gap(px(space::SM)) - .children(message_actions::quote_line(message, chat, palette)) - .when(!message.body.is_empty(), |this| { - this.child( - div() - .min_w_0() - .when(message.body.contains("```"), |this| this.w_full()) - .flex() - .flex_wrap() - .items_baseline() - .gap(px(space::XS)) - .text_size(text(text::BODY)) - .line_height(relative(1.55)) - .text_color(palette.body) - .child( - div() - .min_w_0() - .when(message.body.contains("```"), |this| { - this.w_full() - }) - .child( - TextView::markdown( - format!("message-body-{}", message.id), - hard_breaks(&message.body), - ) - .selectable(true), - ), - ) - .when(message.edited, |this| { - this.child( + .min_w_0() + .max_w(px(size::PAGE)) + .when(message.body.contains("```"), |this| this.w_full()) + .flex() + .flex_col() + .gap(px(space::SM)) + .children(message_actions::quote_line(message, chat, palette)) + .when(!message.body.is_empty(), |this| { + this.child( + div() + .min_w_0() + .when(message.body.contains("```"), |this| this.w_full()) + .flex() + .flex_wrap() + .items_baseline() + .gap(px(space::XS)) + .text_size(text(text::BODY)) + .line_height(relative(1.55)) + .text_color(palette.body) + .child( div() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child("(edited)"), + .min_w_0() + .when(message.body.contains("```"), |this| { + this.w_full() + }) + .child( + TextView::markdown( + format!("message-body-{}", message.id), + hard_breaks(&message.body), + ) + .selectable(true), + ), ) - }), - ) - }) - .children(media_view::attachments( - &message.attachments, - &chat.media, - entity, - palette, - )) - .children(snippet::snippet_card(message, chat, entity, palette)) - .children(message.poll.as_ref().map(|poll| { - poll::poll_card( - poll, - poll::PollMode::Live(message), - me, - chat, + .when(message.edited, |this| { + this.child( + div() + .text_size(text(text::CAPTION)) + .text_color(palette.muted) + .child("(edited)"), + ) + }), + ) + }) + .children(media_view::attachments( + &message.attachments, + &chat.media, entity, palette, - ) - })) - .children(media_view::embeds(message, &chat.media, palette)) - .children( - (!message.reactions.is_empty()) - .then(|| message_actions::reactions(message, me, entity, palette)), - ), - ) - .children(message.pinned.then(|| message_actions::pin_mark(palette))) - .children((!selecting).then(|| { - div() - .absolute() - .right_0() - .top(px(-space::LG)) - .child(message_actions::actions( - message, chat, me, entity, palette, group, - )) - })), - ) - .children( - (chat.report == Some(ReportTarget::Message(message.id))) - .then(|| message_actions::report_bar(&chat.report_reason, entity, palette)), - ); + )) + .children(snippet::snippet_card(message, chat, entity, palette)) + .children(message.poll.as_ref().map(|poll| { + poll::poll_card( + poll, + poll::PollMode::Live(message), + me, + chat, + entity, + palette, + ) + })) + .children(media_view::embeds(message, &chat.media, palette)) + .children( + (!message.reactions.is_empty()).then(|| { + message_actions::reactions(message, me, entity, palette) + }), + ), + ) + .children(message.pinned.then(|| message_actions::pin_mark(palette))) + .children((!selecting).then(|| { + div().absolute().right_0().top(px(-space::LG)).child( + message_actions::actions(message, chat, me, entity, palette, group), + ) + })), + ) + .children( + (chat.report == Some(ReportTarget::Message(message.id))) + .then(|| message_actions::report_bar(&chat.report_reason, entity, palette)), + ); if !selecting { return row.into_any_element(); diff --git a/crates/client/src/gui/community_settings.rs b/crates/client/src/gui/community_settings.rs index f03ff23..751b25a 100644 --- a/crates/client/src/gui/community_settings.rs +++ b/crates/client/src/gui/community_settings.rs @@ -29,8 +29,8 @@ use super::{ clickable, community_icon, entity_action, millis_time, notify_error, profile::user_link, settings_page::{ - Editable, Picture, danger_section, delete_control, page, picked_avatar, picture_card, row, - section, small_button, text_row, + Editable, Picture, Section, danger_section, delete_control, page, picked_avatar, + picture_card, row, section, small_button, text_row, }, style::{radius, size, space, text as text_token}, text, @@ -91,7 +91,8 @@ impl Yumush { let mut sections = Vec::new(); if let Some(community) = community.filter(|_| permission::can_rename_community(actor)) { - sections.push( + sections.push(Section( + "Profile", picture_card( Picture { id: "community_picture_picker", @@ -112,41 +113,35 @@ impl Yumush { palette, ) .into_any_element(), - ); + )); } if permission::can_rename_community(actor) { - sections.push( - section( - "General", + sections.push(section( + "General", + palette, + vec![text_row( + Editable { + id: "save_community_name_button", + label: "Name", + input: &self.chat.community_name_input, + current: &name, + save: Yumush::save_community_name, + }, + entity, palette, - vec![text_row( - Editable { - id: "save_community_name_button", - label: "Name", - input: &self.chat.community_name_input, - current: &name, - save: Yumush::save_community_name, - }, - entity, - palette, - cx, - )], - ) - .into_any_element(), - ); + cx, + )], + )); } if let Some(community) = community.filter(|_| permission::can_manage_voice(actor)) { - sections.push( - section( + sections.push(section( + "Voice", + palette, + vec![row( "Voice", - palette, - vec![row( - "Voice", - voice_control(entity, community.id, community.voice_enabled, palette), - )], - ) - .into_any_element(), - ); + voice_control(entity, community.id, community.voice_enabled, palette), + )], + )); } let mut moderation = Vec::new(); if permission::can_unban(actor) { @@ -177,7 +172,7 @@ impl Yumush { )); } if !moderation.is_empty() { - sections.push(section("Moderation", palette, moderation).into_any_element()); + sections.push(section("Moderation", palette, moderation)); } let mut danger = Vec::new(); if let Some(community) = community.filter(|_| permission::can_leave(actor)) { @@ -199,10 +194,17 @@ impl Yumush { )); } if !danger.is_empty() { - sections.push(danger_section(palette, danger).into_any_element()); + sections.push(danger_section(palette, danger)); } - page("community_settings_scroll", entity, palette, name, sections) + page( + "community_settings_scroll", + entity, + palette, + name, + sections, + self.chat.section, + ) } fn set_community_voice( @@ -554,7 +556,13 @@ fn moderation_body( .gap(px(space::MD)) .child(Input::new(search)) .child(sort) - .child(div().id(id).max_h(px(size::SHEET)).overflow_y_scroll().child(list)) + .child( + div() + .id(id) + .max_h(px(size::SHEET)) + .overflow_y_scroll() + .child(list), + ) } fn ban_list<'a>(bans: &'a [Ban], query: &str, sort: BanSort) -> Vec<&'a Ban> { @@ -623,12 +631,15 @@ fn log_row(entry: &LogEntry, palette: Palette, avatars: &HashMap> .flex() .items_center() .gap(px(space::SM)) - .children( - entry - .actor - .as_ref() - .map(|actor| avatar(palette, actor, px(size::AVATAR), text(text_token::CAPTION), avatars)), - ) + .children(entry.actor.as_ref().map(|actor| { + avatar( + palette, + actor, + px(size::AVATAR), + text(text_token::CAPTION), + avatars, + ) + })) .child(div().flex_1().min_w_0().truncate().child(log_text(entry))) .child( div() @@ -677,7 +688,13 @@ fn ban_row( format!("ban_avatar_{user_id}"), Some(user), &entity, - avatar(palette, user, px(size::AVATAR), text(text_token::CAPTION), avatars), + avatar( + palette, + user, + px(size::AVATAR), + text(text_token::CAPTION), + avatars, + ), )) .child( div() diff --git a/crates/client/src/gui/composer.rs b/crates/client/src/gui/composer.rs index 06ae1fb..1c47ac9 100644 --- a/crates/client/src/gui/composer.rs +++ b/crates/client/src/gui/composer.rs @@ -564,7 +564,12 @@ pub fn format_popover(palette: Palette) -> impl IntoElement { .flex() .items_center() .gap(px(space::MD)) - .child(div().w(px(size::THUMB)).text_color(palette.muted).child(syntax)) + .child( + div() + .w(px(size::THUMB)) + .text_color(palette.muted) + .child(syntax), + ) .child(div().flex_1().child(TextView::markdown(syntax, syntax))) .child( div() diff --git a/crates/client/src/gui/forward.rs b/crates/client/src/gui/forward.rs index 1b07315..9c765e6 100644 --- a/crates/client/src/gui/forward.rs +++ b/crates/client/src/gui/forward.rs @@ -86,7 +86,12 @@ impl Render for Forward { .items_center() .gap(px(space::SM)) .rounded(px(radius::MD)) - .child(yumush.community_badge(community, px(size::ICON), super::text(text::CAPTION), palette)) + .child(yumush.community_badge( + community, + px(size::ICON), + super::text(text::CAPTION), + palette, + )) .child( div() .flex_1() @@ -141,7 +146,10 @@ impl Yumush { let forward = cx.new(|cx| Forward::new(yumush, selected, window, cx)); window.open_dialog(cx, move |dialog, _, _| { - dialog.title("Forward").w(px(size::SHEET)).child(forward.clone()) + dialog + .title("Forward") + .w(px(size::SHEET)) + .child(forward.clone()) }); } diff --git a/crates/client/src/gui/gallery.rs b/crates/client/src/gui/gallery.rs index 9068fdc..8908d29 100644 --- a/crates/client/src/gui/gallery.rs +++ b/crates/client/src/gui/gallery.rs @@ -5,6 +5,7 @@ use gpui_kit::{ Context, IntoElement, ParentElement, Render, Styled, Window, assets::IconName, div, px, }; +use super::call_bar::{self, CallActions, CallBar}; use super::{ parts::{ Fill, Ink, Press, Text, Tone, Voice, band, button, caption, chevron, column, grow, @@ -14,7 +15,6 @@ use super::{ style::{Theme, Tokens, size, space}, }; use crate::settings::FontSize; -use super::call_bar::{self, CallActions, CallBar}; use std::rc::Rc; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -97,7 +97,8 @@ impl Render for Gallery { let page = match self.page.as_str() { "parts" => parts_page(self.state, t).into_any_element(), "call" => call_page(self.state, t).into_any_element(), - other => words(format!("no gallery page {other}"), Text::Body, Ink::Bad, t).into_any_element(), + other => words(format!("no gallery page {other}"), Text::Body, Ink::Bad, t) + .into_any_element(), }; div() .size_full() @@ -132,44 +133,139 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement { }; let lines = stack(space::SM) .child(section("Lines", t)) - .child(caption(name(state, "alice"), voice_line(Some(&live), voice, t), t)) - .child(caption(name(state, "bob"), voice_line(None, Voice::Quiet, t), t)) - .child(caption("carol", voice_line(Some(&bands(3.)), Voice::Live(t.hue(Hue::Violet)), t), t)) + .child(caption( + name(state, "alice"), + voice_line(Some(&live), voice, t), + t, + )) + .child(caption( + name(state, "bob"), + voice_line(None, Voice::Quiet, t), + t, + )) + .child(caption( + "carol", + voice_line(Some(&bands(3.)), Voice::Live(t.hue(Hue::Violet)), t), + t, + )) .child( band(space::MD) .h(px(size::ROW)) .child(words("ping", Text::Caption, Ink::Dim, t)) - .child(div().flex_1().h_full().child(spark( - (0..40).map(|index| (index as f32 * 0.5).sin() * 0.3 + 0.5).collect(), - 40, - if state == State::Bad { t.bad() } else { t.paper() }, - ))) - .child(strong(if state == State::Bad { "212 ms" } else { "24 ms" }, Text::Ui, t)), + .child( + div().flex_1().h_full().child(spark( + (0..40) + .map(|index| (index as f32 * 0.5).sin() * 0.3 + 0.5) + .collect(), + 40, + if state == State::Bad { + t.bad() + } else { + t.paper() + }, + )), + ) + .child(strong( + if state == State::Bad { + "212 ms" + } else { + "24 ms" + }, + Text::Ui, + t, + )), ); let rows = column() .child(section("Rows", t)) - .child(row(name(state, "Noise suppression"), toggle("g_toggle", true, t, |_, _| {}), t)) + .child(row( + name(state, "Noise suppression"), + toggle("g_toggle", true, t, |_, _| {}), + t, + )) .child(row("Mute", toggle("g_toggle_off", false, t, |_, _| {}), t)) .child(row( "Mode", - options("g_mode", [(0, "Voice activity"), (1, "Push to talk")], 0, t, |_, _, _| {}), + options( + "g_mode", + [(0, "Voice activity"), (1, "Push to talk")], + 0, + t, + |_, _, _| {}, + ), + t, + )) + .child(row( + "CPU", + band(space::MD) + .w(px(size::POPOVER)) + .child(track( + Fill::Over { + own: 0.09, + total: 0.31, + }, + false, + t, + )) + .child(words("9 / 31 %", Text::Label, Ink::Paper, t)), t, )) - .child(row("CPU", band(space::MD).w(px(size::POPOVER)).child(track(Fill::Over { own: 0.09, total: 0.31 }, false, t)).child(words("9 / 31 %", Text::Label, Ink::Paper, t)), t)) - .child(row("Loss", band(space::MD).w(px(size::POPOVER)).child(track(Fill::Part(0.42), state == State::Bad, t)).child(words("4.2 %", Text::Label, if state == State::Bad { Ink::Bad } else { Ink::Paper }, t)), t)); + .child(row( + "Loss", + band(space::MD) + .w(px(size::POPOVER)) + .child(track(Fill::Part(0.42), state == State::Bad, t)) + .child(words( + "4.2 %", + Text::Label, + if state == State::Bad { + Ink::Bad + } else { + Ink::Paper + }, + t, + )), + t, + )); let controls = stack(space::MD) .child(section("Controls", t)) .child( band(space::XS) - .child(icon_button("g_mic", IconName::Mic, "Mute", Tone::Idle, t, |_, _| {})) + .child(icon_button( + "g_mic", + IconName::Mic, + "Mute", + Tone::Idle, + t, + |_, _| {}, + )) .child(chevron("g_mic_more", false, t, |_, _| {})) - .child(icon_button("g_cam", IconName::Camera, "Camera", Tone::On, t, |_, _| {})) + .child(icon_button( + "g_cam", + IconName::Camera, + "Camera", + Tone::On, + t, + |_, _| {}, + )) .child(chevron("g_cam_more", true, t, |_, _| {})) - .child(icon_button("g_leave", IconName::PhoneOff, "Leave", Tone::Danger, t, |_, _| {})), + .child(icon_button( + "g_leave", + IconName::PhoneOff, + "Leave", + Tone::Danger, + t, + |_, _| {}, + )), ) .child( band(space::XL) - .child(button("g_plain", "Change source", Press::Plain, t, |_, _| {})) + .child(button( + "g_plain", + "Change source", + Press::Plain, + t, + |_, _| {}, + )) .child(button("g_stop", "Stop", Press::Danger, t, |_, _| {})) .child(button("g_share", "Share", Press::Primary, t, |_, _| {})), ) @@ -178,7 +274,13 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement { .w(px(size::SIDEBAR)) .child(index_item("g_i1", "Profile", false, t, |_, _| {})) .child(index_item("g_i2", "Voice", true, t, |_, _| {})) - .child(index_item("g_i3", name(state, "Camera & share"), false, t, |_, _| {})), + .child(index_item( + "g_i3", + name(state, "Camera & share"), + false, + t, + |_, _| {}, + )), ); let pop = popover(t) .w(px(size::POPOVER)) @@ -186,14 +288,27 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement { .child(section("Microphone", t)) .child(words("Shure MV7", Text::Ui, Ink::Paper, t)) .child(words("Laptop mic", Text::Ui, Ink::Dim, t)) - .child(div().h(px(size::ICON)).child(voice_line(Some(&live), voice, t))) - .child(row("Noise suppression", toggle("g_pop_toggle", true, t, |_, _| {}), t)); + .child( + div() + .h(px(size::ICON)) + .child(voice_line(Some(&live), voice, t)), + ) + .child(row( + "Noise suppression", + toggle("g_pop_toggle", true, t, |_, _| {}), + t, + )); band(space::XXL) .items_start() .size_full() .p(px(space::XXL)) .child(stack(space::XL).flex_1().child(lines).child(rows)) - .child(stack(space::XL).w(px(size::TALK + size::CONTROL)).child(controls).child(pop)) + .child( + stack(space::XL) + .w(px(size::TALK + size::CONTROL)) + .child(controls) + .child(pop), + ) .child(grow()) } diff --git a/crates/client/src/gui/message_actions.rs b/crates/client/src/gui/message_actions.rs index d4372e7..9734f5a 100644 --- a/crates/client/src/gui/message_actions.rs +++ b/crates/client/src/gui/message_actions.rs @@ -165,7 +165,15 @@ pub fn quote_line(message: &Message, chat: &Chat, palette: Palette) -> Option, style: Text, t: Tokens) -> Div { } pub fn thread(t: Tokens) -> Div { - div().w_full().h(px(stroke::LINE)).flex_none().bg(t.thread()) + div() + .w_full() + .h(px(stroke::LINE)) + .flex_none() + .bg(t.thread()) } pub fn grow() -> Div { @@ -96,7 +99,11 @@ pub fn row(label: impl Into, trailing: impl IntoElement, t: Tokens band(space::XL) .min_h(px(size::ROW)) .py(px(space::SM)) - .child(words(label, Text::Ui, Ink::Paper, t).flex_shrink_0().max_w(gpui_kit::relative(0.5))) + .child( + words(label, Text::Ui, Ink::Paper, t) + .flex_shrink_0() + .max_w(gpui_kit::relative(0.5)), + ) .child(grow()) .child(trailing), ) @@ -134,7 +141,12 @@ pub fn track(fill: Fill, bad: bool, t: Tokens) -> Div { } } -pub fn toggle(id: impl Into, on: bool, t: Tokens, flip: impl Fn(&mut Window, &mut App) + 'static) -> Stateful
{ +pub fn toggle( + id: impl Into, + on: bool, + t: Tokens, + flip: impl Fn(&mut Window, &mut App) + 'static, +) -> Stateful
{ let (bar, knob, left) = if on { (t.hue(common::model::Hue::Amber), t.paper(), 20.) } else { @@ -147,8 +159,24 @@ pub fn toggle(id: impl Into, on: bool, t: Tokens, flip: impl Fn(&mut .w(px(30.)) .h(px(14.)) .on_click(move |_, window, cx| flip(window, cx)) - .child(div().absolute().left_0().right_0().top(px(6.)).h(px(stroke::LINE)).bg(bar)) - .child(div().absolute().top(px(2.)).left(px(left)).size(px(10.)).rounded_full().bg(knob)) + .child( + div() + .absolute() + .left_0() + .right_0() + .top(px(6.)) + .h(px(stroke::LINE)) + .bg(bar), + ) + .child( + div() + .absolute() + .top(px(2.)) + .left(px(left)) + .size(px(10.)) + .rounded_full() + .bg(knob), + ) } pub fn options( @@ -166,8 +194,15 @@ pub fn options( .id(ElementId::Name(format!("{id}_{label}").into())) .cursor_pointer() .on_click(move |_, window, cx| pick(item, window, cx)) - .child(words(label, Text::Ui, if on { Ink::Paper } else { Ink::Dim }, t).font_weight(FontWeight::MEDIUM)) - .child(div().h(px(stroke::LINE)).bg(if on { t.paper() } else { gpui_kit::transparent_black() })) + .child( + words(label, Text::Ui, if on { Ink::Paper } else { Ink::Dim }, t) + .font_weight(FontWeight::MEDIUM), + ) + .child(div().h(px(stroke::LINE)).bg(if on { + t.paper() + } else { + gpui_kit::transparent_black() + })) })) } @@ -192,15 +227,23 @@ pub fn button( .on_click(move |_, window, cx| on_click(window, cx)); let label = label.into(); match kind { - Press::Plain => base.child(words(label, Text::Ui, Ink::Paper, t).font_weight(FontWeight::MEDIUM)), - Press::Danger => base.child(words(label, Text::Ui, Ink::Bad, t).font_weight(FontWeight::MEDIUM)), + Press::Plain => { + base.child(words(label, Text::Ui, Ink::Paper, t).font_weight(FontWeight::MEDIUM)) + } + Press::Danger => { + base.child(words(label, Text::Ui, Ink::Bad, t).font_weight(FontWeight::MEDIUM)) + } Press::Primary => base .px(px(space::LG + 2.)) .h(px(32.)) .rounded_full() .bg(t.paper()) .hover(|style| style.opacity(0.9)) - .child(words(label, Text::Ui, Ink::Paper, t).font_weight(FontWeight::SEMIBOLD).text_color(t.ground())), + .child( + words(label, Text::Ui, Ink::Paper, t) + .font_weight(FontWeight::SEMIBOLD) + .text_color(t.ground()), + ), } } @@ -292,7 +335,11 @@ pub fn index_item( on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> Stateful
{ let ink = if selected { Ink::Paper } else { Ink::Dim }; - let weight = if selected { FontWeight::MEDIUM } else { FontWeight::NORMAL }; + let weight = if selected { + FontWeight::MEDIUM + } else { + FontWeight::NORMAL + }; band(space::MD) .id(id) .cursor_pointer() @@ -309,7 +356,9 @@ pub enum Voice { } pub fn voice_line(bands: Option<&VecDeque>, voice: Voice, t: Tokens) -> AnyElement { - let levels: Vec = bands.map(|bands| bands.iter().copied().collect()).unwrap_or_default(); + let levels: Vec = bands + .map(|bands| bands.iter().copied().collect()) + .unwrap_or_default(); let color = match voice { Voice::Quiet => t.off(), Voice::Live(color) => color, @@ -375,7 +424,11 @@ pub fn pop_in( element: E, anchor: gpui_kit::Anchor, ) -> gpui_kit::AnimationElement { - let travel = if anchor.is_bottom() { MOTION_TRAVEL } else { -MOTION_TRAVEL }; + let travel = if anchor.is_bottom() { + MOTION_TRAVEL + } else { + -MOTION_TRAVEL + }; gpui_kit::AnimationExt::with_animation(element, id, motion(), move |element, delta| { element.top(px(travel * (1. - delta))).opacity(delta) }) @@ -386,7 +439,11 @@ pub fn swap_in( element: E, forward: bool, ) -> gpui_kit::AnimationElement { - let travel = if forward { MOTION_TRAVEL } else { -MOTION_TRAVEL }; + let travel = if forward { + MOTION_TRAVEL + } else { + -MOTION_TRAVEL + }; gpui_kit::AnimationExt::with_animation(element, id, motion(), move |element, delta| { element.left(px(travel * (1. - delta))).opacity(delta) }) diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index 9e6fed3..e73524f 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -11,8 +11,9 @@ use gpui_kit::{ use super::{ Palette, Tooltip as _, Trigger, Yumush, avatar, chat::Chat, - clickable, hoverable, pop_in, text, + clickable, hoverable, pop_in, style::{radius, size, space, text}, + text, widget::{icon_button, panel, spawn_done}, }; @@ -125,7 +126,13 @@ fn voters_popover(key: &str, poll: &Poll, entity: &Entity, palette: Pale .items_center() .gap(px(space::SM)) .text_size(text(text::CAPTION)) - .child(avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &chat.avatars)) + .child(avatar( + palette, + user, + px(size::AVATAR), + text(text::CAPTION), + &chat.avatars, + )) .child( div() .flex_1() @@ -285,10 +292,16 @@ pub fn poll_card( .enumerate() .filter_map(|(index, id)| { chat.author(*id).map(|user| { - avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &chat.avatars) - .border_2() - .border_color(palette.panel) - .when(index > 0, |el| el.ml(px(-space::SM))) + avatar( + palette, + user, + px(size::AVATAR), + text(text::CAPTION), + &chat.avatars, + ) + .border_2() + .border_color(palette.panel) + .when(index > 0, |el| el.ml(px(-space::SM))) }) }), ) diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index f926f35..e2add24 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -23,12 +23,12 @@ use gpui_kit::{ use super::chat::{CardMenu, ReportTarget, View}; use super::message_actions::report_bar; use super::social::Relation; +use super::style::{radius, size, space, stroke, text}; use super::widget::{panel, spawn_done}; use super::{ DAY_YEAR, Palette, Trigger, Yumush, avatar, clickable, entity_action, input_dialog, millis_time, notify_error, palette, pop_in, presence_color, rank_tag, swap_in, text, }; -use super::style::{radius, size, space, stroke, text}; const ACCOUNTS_MAX_H: f32 = 180.; @@ -223,7 +223,12 @@ impl Card { rows.extend(self.moderation_rows(entity, &popover, palette)); rows }; - let divider = (!rows.is_empty()).then(|| div().h(px(stroke::LINE)).my(px(space::XS)).bg(palette.border)); + let divider = (!rows.is_empty()).then(|| { + div() + .h(px(stroke::LINE)) + .my(px(space::XS)) + .bg(palette.border) + }); panel(palette) .w(px(size::SIDEBAR)) @@ -231,7 +236,13 @@ impl Card { .flex() .flex_col() .gap(px(space::MD)) - .child(avatar(palette, &self.user, px(size::AVATAR_LG), text(text::BODY), avatars)) + .child(avatar( + palette, + &self.user, + px(size::AVATAR_LG), + text(text::BODY), + avatars, + )) .child( div() .flex() @@ -279,7 +290,12 @@ impl Card { .text_color(palette.muted) .child(Icon::new(IconName::Volume2).size(px(size::ICON_SM))) .child(Slider::new(&slider).flex_1()) - .child(div().w(px(size::CONTROL)).text_right().child(format!("{volume:.0}%"))) + .child( + div() + .w(px(size::CONTROL)) + .text_right() + .child(format!("{volume:.0}%")), + ) })) .children( self.reporting diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index 33e92f4..0ba10c3 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -10,18 +10,15 @@ use gpui_kit::{ InteractiveElement, IntoElement, ParentElement, PathPromptOptions, Stateful, StatefulInteractiveElement, Styled, WeakEntity, Window, assets::IconName, - component::input::InputState, + component::{Icon, input::InputState}, div, prelude::FluentBuilder as _, px, transparent_black, }; use super::{ - Palette, Tooltip as _, Yumush, avatar, - chat::DeleteStep, - chat::View, - clickable, notify_error, primary_button, text, - widget::{field, icon_button}, + Palette, Tooltip as _, Yumush, avatar, chat::DeleteStep, chat::View, clickable, notify_error, + primary_button, text, widget::field, }; use crate::{ gui::style::{Theme, radius, size, space, stroke, text}, @@ -37,11 +34,18 @@ impl Yumush { ) -> impl IntoElement { let mut sections = Vec::new(); if let Some(user) = self.user.as_ref() { - sections.push( + sections.push(Section( + "Profile", picture_card( Picture { id: "avatar_picker", - image: avatar(palette, user, px(size::AVATAR_LG), text(text::TITLE), &self.chat.avatars), + image: avatar( + palette, + user, + px(size::AVATAR_LG), + text(text::TITLE), + &self.chat.avatars, + ), title: user.username.clone(), subtitle: user.status.clone(), removable: user.avatar_id.is_some(), @@ -52,110 +56,110 @@ impl Yumush { palette, ) .into_any_element(), - ); - sections.push( - section( - "Account", - palette, - vec![ - text_row( - Editable { - id: "save_username_button", - label: "Username", - input: &self.chat.username_input, - current: &user.username, - save: Yumush::save_username, - }, - entity, - palette, - cx, - ), - text_row( - Editable { - id: "save_status_button", - label: "Status", - input: &self.chat.status_input, - current: &user.status, - save: Yumush::save_status, - }, - entity, - palette, - cx, - ), - ], - ) - .into_any_element(), - ); - } - sections.push( - section("Voice", palette, self.voice_rows(entity, palette, cx)).into_any_element(), - ); - sections.push( - section( - "Appearance", + )); + sections.push(section( + "Account", palette, vec![ - row( - "Theme", - segmented( - Theme::ALL.map(|choice| (choice, choice.label())), - self.settings.theme, - entity, - palette, - Yumush::set_theme, - ), + text_row( + Editable { + id: "save_username_button", + label: "Username", + input: &self.chat.username_input, + current: &user.username, + save: Yumush::save_username, + }, + entity, + palette, + cx, ), - row( - "Font size", - segmented( - FontSize::ALL.map(|size| (size, size.label())), - self.settings.font_size, - entity, - palette, - Yumush::set_font_size, - ), - ), - row( - "Close to tray", - super::parts::toggle( - "close_to_tray_switch", - self.settings.close_to_tray, - palette.tokens, - { - let entity = entity.clone(); - move |_, cx| { - entity.update(cx, |yumush, cx| { - yumush.settings.close_to_tray = !yumush.settings.close_to_tray; - yumush.commit_settings(cx); - }) - } - }, - ), + text_row( + Editable { + id: "save_status_button", + label: "Status", + input: &self.chat.status_input, + current: &user.status, + save: Yumush::save_status, + }, + entity, + palette, + cx, ), ], - ) - .into_any_element(), - ); + )); + } + sections.push(section( + "Voice", + palette, + self.voice_rows(entity, palette, cx), + )); + sections.push(section( + "Appearance", + palette, + vec![ + row( + "Theme", + segmented( + Theme::ALL.map(|choice| (choice, choice.label())), + self.settings.theme, + entity, + palette, + Yumush::set_theme, + ), + ), + row( + "Font size", + segmented( + FontSize::ALL.map(|size| (size, size.label())), + self.settings.font_size, + entity, + palette, + Yumush::set_font_size, + ), + ), + row( + "Close to tray", + super::parts::toggle( + "close_to_tray_switch", + self.settings.close_to_tray, + palette.tokens, + { + let entity = entity.clone(); + move |_, cx| { + entity.update(cx, |yumush, cx| { + yumush.settings.close_to_tray = !yumush.settings.close_to_tray; + yumush.commit_settings(cx); + }) + } + }, + ), + ), + ], + )); if self.user.is_some() { - sections.push( - danger_section( - palette, - vec![row( - "Delete account", - delete_control( - "delete_account_button", - self.chat.delete_step, - entity, - palette, - Yumush::delete_account, - ), - )], - ) - .into_any_element(), - ); + sections.push(danger_section( + palette, + vec![row( + "Delete account", + delete_control( + "delete_account_button", + self.chat.delete_step, + entity, + palette, + Yumush::delete_account, + ), + )], + )); } - page("settings_scroll", entity, palette, "Settings", sections) + page( + "settings_scroll", + entity, + palette, + "Settings", + sections, + self.chat.section, + ) } pub(super) fn set_user(&mut self, user: User, cx: &mut Context) { @@ -310,31 +314,61 @@ pub(super) fn header( div() .h(px(size::ROW)) - .px(px(space::MD)) + .px(px(space::LG)) .flex() .items_center() - .gap(px(space::SM)) - .border_b_1() - .border_color(palette.border) - .child(icon_button( - "settings_back_button", - palette, - IconName::ArrowLeft, - "Back", - move |window, cx| { + .child( + clickable("settings_back_button", palette, move |window, cx| { entity.update(cx, |yumush, cx| yumush.show_view(View::Chat, window, cx)); - }, - )) - .child(div().font_weight(FontWeight::SEMIBOLD).child(title)) + }) + .tip("Back") + .h(px(size::CONTROL_SM)) + .px(px(space::SM)) + .rounded(px(radius::MD)) + .flex() + .items_center() + .gap(px(space::XS)) + .font_weight(FontWeight::MEDIUM) + .child(Icon::new(IconName::ChevronLeft).size(px(size::ICON_SM))) + .child(title), + ) } +pub(super) struct Section(pub &'static str, pub AnyElement); + pub(super) fn page( id: &'static str, entity: &Entity, palette: Palette, title: impl IntoElement, - sections: Vec, + sections: Vec
, + selected: usize, ) -> impl IntoElement { + let selected = selected.min(sections.len().saturating_sub(1)); + let index: Vec<_> = sections + .iter() + .enumerate() + .map(|(position, Section(name, _))| { + let entity = entity.clone(); + super::parts::index_item( + gpui_kit::ElementId::Name(format!("{id}_index_{name}").into()), + *name, + position == selected, + palette.tokens, + move |_, cx| { + entity.update(cx, |yumush, cx| { + yumush.chat.section = position; + cx.notify(); + }) + }, + ) + }) + .collect(); + let body = sections + .into_iter() + .nth(selected) + .map(|Section(_, body)| body); + div() .flex_1() .min_h_0() @@ -343,62 +377,56 @@ pub(super) fn page( .child(header(entity, palette, title)) .child( div() - .id(id) .flex_1() .min_h_0() - .overflow_y_scroll() .flex() - .justify_center() .child( div() - .w_full() - .max_w(px(size::PAGE)) + .w(px(size::SIDEBAR)) + .flex_shrink_0() .px(px(space::XL)) - .py(px(space::XXL)) + .py(px(space::LG)) .flex() .flex_col() - .gap(px(space::XXL)) - .children(sections), + .children(index), + ) + .child( + div() + .id(id) + .flex_1() + .min_w_0() + .min_h_0() + .overflow_y_scroll() + .child( + div() + .w_full() + .max_w(px(size::PAGE)) + .px(px(space::XL)) + .py(px(space::LG)) + .children(body), + ), ), ) } -pub(super) fn section(title: &'static str, palette: Palette, rows: Vec
) -> impl IntoElement { - card(title, palette.muted, palette, rows) +pub(super) fn section(title: &'static str, palette: Palette, rows: Vec
) -> Section { + Section(title, rows_column(palette, rows)) } -pub(super) fn danger_section(palette: Palette, rows: Vec
) -> impl IntoElement { - card("Danger zone", palette.danger, palette, rows) +pub(super) fn danger_section(palette: Palette, rows: Vec
) -> Section { + Section("Danger zone", rows_column(palette, rows)) } -fn card( - title: &'static str, - title_color: Hsla, - palette: Palette, - rows: Vec
, -) -> impl IntoElement { +fn rows_column(palette: Palette, rows: Vec
) -> AnyElement { div() .flex() .flex_col() - .gap(px(space::SM)) - .child( - div() - .px(px(space::XXS)) - .text_size(text(text::CAPTION)) - .font_weight(FontWeight::MEDIUM) - .text_color(title_color) - .child(title), - ) - .child( - div() - .flex() - .flex_col() - .children(rows.into_iter().enumerate().map(|(index, row)| { - row.when(index > 0, |row| { - row.border_t_1().border_color(palette.border) - }) - })), - ) + .children(rows.into_iter().enumerate().map(|(index, row)| { + row.when(index > 0, |row| { + row.border_t_1().border_color(palette.border) + }) + })) + .into_any_element() } pub(super) struct Editable<'a> { @@ -628,7 +656,11 @@ pub(super) fn segmented( .gap(px(space::XXS)) .text_size(text(text::UI)) .font_weight(FontWeight::MEDIUM) - .text_color(if on { palette.tokens.paper() } else { palette.muted }) + .text_color(if on { + palette.tokens.paper() + } else { + palette.muted + }) .on_click(move |_, _, cx| { entity.update(cx, |yumush, cx| select(yumush, choice, cx)); }) diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index f1b302d..472011f 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -947,20 +947,18 @@ fn include_row( let included = !is_excluded(&settings.excluded, &app.name, app.pid); let target = app.clone(); - row_style(div()).child(name_cell(app, palette)).child( - div().flex_shrink_0().child( - super::parts::toggle( - gpui_kit::ElementId::Name(format!("share_app_{}", app.key()).into()), - included, - palette.tokens, - move |_, cx| { - entity.update(cx, |yumush, cx| { - yumush.set_share_included(&target, !included, cx) - }); - }, - ), - ), - ) + row_style(div()) + .child(name_cell(app, palette)) + .child(div().flex_shrink_0().child(super::parts::toggle( + gpui_kit::ElementId::Name(format!("share_app_{}", app.key()).into()), + included, + palette.tokens, + move |_, cx| { + entity.update(cx, |yumush, cx| { + yumush.set_share_included(&target, !included, cx) + }); + }, + ))) } fn pick_row( diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index f7c164a..60e97c8 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -235,7 +235,11 @@ impl Yumush { .min_w_0() .truncate() .text_size(text(text::LABEL)) - .text_color(if speaking { palette.text } else { palette.muted }) + .text_color(if speaking { + palette.text + } else { + palette.muted + }) .when(speaking, |name| name.font_weight(FontWeight::SEMIBOLD)) .child(user.username.clone()), ) @@ -686,7 +690,13 @@ impl Yumush { palette, false, presence_avatar( - avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), + avatar( + palette, + user, + px(size::AVATAR), + text(text::CAPTION), + &self.chat.avatars, + ), self.presence_of(user.id), px(size::AVATAR), palette, @@ -835,7 +845,13 @@ impl Yumush { .px(px(space::SM)) .rounded(px(radius::MD)) .child(presence_avatar( - avatar(palette, user, px(size::AVATAR), text(text::CAPTION), &self.chat.avatars), + avatar( + palette, + user, + px(size::AVATAR), + text(text::CAPTION), + &self.chat.avatars, + ), self.presence_of(user.id), px(size::AVATAR), palette, @@ -922,7 +938,11 @@ fn watch_pill( .child( Icon::new(icon) .size(px(size::ICON_SM)) - .text_color(if watching { palette.text } else { palette.muted }), + .text_color(if watching { + palette.text + } else { + palette.muted + }), ) .children(wave.map(|history| mini_wave(history, 10., palette.screen))) } diff --git a/crates/client/src/gui/snippet.rs b/crates/client/src/gui/snippet.rs index 77dc66f..d72e5a8 100644 --- a/crates/client/src/gui/snippet.rs +++ b/crates/client/src/gui/snippet.rs @@ -66,7 +66,13 @@ fn snippet_row( format!("snippet_avatar_{}", item.id), Some(&user), entity, - avatar(palette, &user, px(size::AVATAR), super::text(text::CAPTION), &chat.avatars), + avatar( + palette, + &user, + px(size::AVATAR), + super::text(text::CAPTION), + &chat.avatars, + ), )) .child( div() diff --git a/crates/client/src/gui/social.rs b/crates/client/src/gui/social.rs index f886d36..096cb61 100644 --- a/crates/client/src/gui/social.rs +++ b/crates/client/src/gui/social.rs @@ -21,8 +21,9 @@ use gpui_kit::{ }; use super::{ - Palette, Yumush, avatar, new_input, notify_error, primary_button, text, + Palette, Yumush, avatar, new_input, notify_error, primary_button, style::{radius, size, space}, + text, widget::{search_text, spawn_done}, }; diff --git a/crates/client/src/gui/style.rs b/crates/client/src/gui/style.rs index fcaa038..4e14b0d 100644 --- a/crates/client/src/gui/style.rs +++ b/crates/client/src/gui/style.rs @@ -143,7 +143,9 @@ mod tests { let literal = |pattern: &str| { line.match_indices(pattern).any(|(at, _)| { let rest = &line[at + pattern.len()..]; - rest.chars().next().is_some_and(|next| next.is_ascii_digit()) + rest.chars() + .next() + .is_some_and(|next| next.is_ascii_digit()) && !rest.starts_with("0.)") && !rest.starts_with("0.0)") }) @@ -166,7 +168,11 @@ mod tests { sources(&src.join("gui"), &mut files); let mut found = Vec::new(); for file in files { - let name = file.strip_prefix(&src).expect("under src").to_string_lossy().replace('\\', "/"); + let name = file + .strip_prefix(&src) + .expect("under src") + .to_string_lossy() + .replace('\\', "/"); if FREE.contains(&name.as_str()) || UNMIGRATED.contains(&name.as_str()) { continue; } @@ -177,6 +183,10 @@ mod tests { } } } - assert!(found.is_empty(), "raw values outside tokens:\n{}", found.join("\n")); + assert!( + found.is_empty(), + "raw values outside tokens:\n{}", + found.join("\n") + ); } } diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index 54b4d1a..857dabb 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -220,11 +220,19 @@ impl Yumush { let mut rows = vec![ row( "Input device", - div().child(Select::new(&controls.inputs).w(px(size::SIDEBAR))), + div().child( + Select::new(&controls.inputs) + .appearance(false) + .w(px(size::SIDEBAR)), + ), ), row( "Output device", - div().child(Select::new(&controls.outputs).w(px(size::SIDEBAR))), + div().child( + Select::new(&controls.outputs) + .appearance(false) + .w(px(size::SIDEBAR)), + ), ), row( "Input volume", @@ -540,11 +548,6 @@ fn test_button( .items_center() .gap(px(space::SM)) .rounded(px(radius::MD)) - .border_1() - .border_color(if active { - palette.accent - } else { - palette.border - }) - .text_color(if active { palette.text } else { palette.body }) + .font_weight(gpui_kit::FontWeight::MEDIUM) + .text_color(if active { palette.text } else { palette.muted }) } diff --git a/crates/client/src/gui/voice_stats.rs b/crates/client/src/gui/voice_stats.rs index 11dc8e5..28bc8b6 100644 --- a/crates/client/src/gui/voice_stats.rs +++ b/crates/client/src/gui/voice_stats.rs @@ -252,7 +252,9 @@ fn layer_row(index: usize, stats: &LayerStats, max: f32, kind: Kind, palette: Pa .rounded(px(radius::MD)) .bg(palette.hover) .text_size(text_size(text::CAPTION)) - .when(stats.kbps == 0, |this| this.text_color(palette.tokens.faint())) + .when(stats.kbps == 0, |this| { + this.text_color(palette.tokens.faint()) + }) .child( div() .w(px(size::CHIP)) @@ -335,11 +337,15 @@ fn watch_row(chat: &Chat, user_id: Id, kind: Kind, stats: &WatchStats, palette: .text_color(kind_color(kind, palette)), ) .child( - div().w(px(WATCH_LAYER_W)).flex_none().text_color(palette.text).child( - stats - .layer - .map_or("…".to_string(), |layer| resolution_text(layer, stats.fps)), - ), + div() + .w(px(WATCH_LAYER_W)) + .flex_none() + .text_color(palette.text) + .child( + stats + .layer + .map_or("…".to_string(), |layer| resolution_text(layer, stats.fps)), + ), ) .child( div() @@ -418,7 +424,12 @@ fn usage_block(usage: &Usage, palette: Palette) -> Div { } fn column() -> Div { - div().flex().flex_col().gap(px(space::SM)).flex_1().min_w_0() + div() + .flex() + .flex_col() + .gap(px(space::SM)) + .flex_1() + .min_w_0() } fn model_header(icon: IconName, title: &'static str, model: &str, palette: Palette) -> Div { @@ -604,7 +615,10 @@ fn header(icon: IconName, title: &'static str, color: Hsla) -> Div { } fn label(value: &'static str, color: Hsla) -> Div { - div().text_size(text_size(text::CAPTION)).text_color(color).child(value) + div() + .text_size(text_size(text::CAPTION)) + .text_color(color) + .child(value) } fn chip(value: impl gpui_kit::IntoElement, color: Hsla, palette: Palette) -> Div { @@ -632,7 +646,12 @@ fn stat_cell(label: &'static str, value: String, color: Hsla, palette: Palette) .text_color(palette.muted) .child(label), ) - .child(div().text_size(text_size(text::UI)).text_color(color).child(value)) + .child( + div() + .text_size(text_size(text::UI)) + .text_color(color) + .child(value), + ) } fn avatar_dot(name: &str, color: Hsla, palette: Palette) -> Div {