diff --git a/crates/client/lang/en/builder.txt b/crates/client/lang/en/builder.txt index fe16324..0960692 100644 --- a/crates/client/lang/en/builder.txt +++ b/crates/client/lang/en/builder.txt @@ -1,7 +1,6 @@ overview = Overview users = Users communities = Communities -messages = Messages voice = Voice storage = Storage access = Access diff --git a/crates/client/lang/en/builder_access.txt b/crates/client/lang/en/builder_access.txt index 59b1c77..d3ae7b6 100644 --- a/crates/client/lang/en/builder_access.txt +++ b/crates/client/lang/en/builder_access.txt @@ -9,4 +9,3 @@ create = Create invite_codes = Invite codes bans = Bans no_invite_codes = No invite codes -no_bans = No bans diff --git a/crates/client/lang/en/builder_overview.txt b/crates/client/lang/en/builder_overview.txt index e832bbb..ca270e3 100644 --- a/crates/client/lang/en/builder_overview.txt +++ b/crates/client/lang/en/builder_overview.txt @@ -1,9 +1,7 @@ users = Users builders = Builders communities = Communities -online = Online in_voice = In voice storage = Storage active_users = Active users -messages = Messages server = Server diff --git a/crates/client/lang/en/builder_users.txt b/crates/client/lang/en/builder_users.txt index 81ac469..8d72c1c 100644 --- a/crates/client/lang/en/builder_users.txt +++ b/crates/client/lang/en/builder_users.txt @@ -2,7 +2,6 @@ seen_never = never seen_now = now seen_minutes = {count}m ago seen_hours = {count}h ago -no_users = No users create = Create confirm = Confirm revoke = Revoke diff --git a/crates/client/lang/en/builder_voice.txt b/crates/client/lang/en/builder_voice.txt index 16b269b..584addf 100644 --- a/crates/client/lang/en/builder_voice.txt +++ b/crates/client/lang/en/builder_voice.txt @@ -2,7 +2,6 @@ no_rooms = No active voice rooms join = Join voice_on = Voice on voice_off = Voice off -no_users = No users muted = Muted ghost = Ghost unmute = Unmute diff --git a/crates/client/lang/en/camera_view.txt b/crates/client/lang/en/camera_view.txt index 3e1d41e..975e452 100644 --- a/crates/client/lang/en/camera_view.txt +++ b/crates/client/lang/en/camera_view.txt @@ -1,3 +1,2 @@ watch = Watch screens = screens -more = {count} more diff --git a/crates/client/lang/en/chat.txt b/crates/client/lang/en/chat.txt index 1b70329..e7d6573 100644 --- a/crates/client/lang/en/chat.txt +++ b/crates/client/lang/en/chat.txt @@ -47,8 +47,6 @@ grid = Grid hide = Hide stats = Connection stats stats_hide = Hide connection stats -online = Online -offline = Offline new = New edited = (edited) calls = {count} calls diff --git a/crates/client/lang/en/common.txt b/crates/client/lang/en/common.txt index af2fd8e..2143ae1 100644 --- a/crates/client/lang/en/common.txt +++ b/crates/client/lang/en/common.txt @@ -18,3 +18,7 @@ year_stamp = %b %-d %Y, %H:%M day = %b %-d day_year = %b %-d, %Y date = %b %-d %Y +more = {count} more +messages = Messages +no_users = No users +no_bans = No bans diff --git a/crates/client/lang/en/community_card.txt b/crates/client/lang/en/community_card.txt index 9817830..f8eefc4 100644 --- a/crates/client/lang/en/community_card.txt +++ b/crates/client/lang/en/community_card.txt @@ -1,2 +1 @@ people = {members} members · {online} online -more = {count} more diff --git a/crates/client/lang/en/community_settings.txt b/crates/client/lang/en/community_settings.txt index f68aeb7..a5b78c0 100644 --- a/crates/client/lang/en/community_settings.txt +++ b/crates/client/lang/en/community_settings.txt @@ -13,7 +13,6 @@ on = On off = Off view = View unban = Unban -no_bans = No bans no_logs = No logs someone = someone created = {actor} created the community diff --git a/crates/client/lang/en/message_actions.txt b/crates/client/lang/en/message_actions.txt index ca80c37..ec7cc7e 100644 --- a/crates/client/lang/en/message_actions.txt +++ b/crates/client/lang/en/message_actions.txt @@ -10,4 +10,3 @@ confirm = Confirm delete = Delete send = Send people = People -messages = Messages diff --git a/crates/client/lang/tr/builder.txt b/crates/client/lang/tr/builder.txt index 7101715..d8004a7 100644 --- a/crates/client/lang/tr/builder.txt +++ b/crates/client/lang/tr/builder.txt @@ -1,7 +1,6 @@ overview = Genel Bakış users = Kullanıcılar communities = Topluluklar -messages = Mesajlar voice = Ses storage = Depolama access = Erişim diff --git a/crates/client/lang/tr/builder_access.txt b/crates/client/lang/tr/builder_access.txt index 04f1682..f793636 100644 --- a/crates/client/lang/tr/builder_access.txt +++ b/crates/client/lang/tr/builder_access.txt @@ -9,4 +9,3 @@ create = Oluştur invite_codes = Davet kodları bans = Yasaklar no_invite_codes = Davet kodu yok -no_bans = Yasak yok diff --git a/crates/client/lang/tr/builder_overview.txt b/crates/client/lang/tr/builder_overview.txt index f8985fa..23a6a42 100644 --- a/crates/client/lang/tr/builder_overview.txt +++ b/crates/client/lang/tr/builder_overview.txt @@ -1,9 +1,7 @@ users = Kullanıcılar builders = Kurucular communities = Topluluklar -online = Çevrimiçi in_voice = Seste storage = Depolama active_users = Aktif kullanıcılar -messages = Mesajlar server = Sunucu diff --git a/crates/client/lang/tr/builder_users.txt b/crates/client/lang/tr/builder_users.txt index d1d2628..255f546 100644 --- a/crates/client/lang/tr/builder_users.txt +++ b/crates/client/lang/tr/builder_users.txt @@ -2,7 +2,6 @@ seen_never = hiç seen_now = şimdi seen_minutes = {count} dk önce seen_hours = {count} sa önce -no_users = Kullanıcı yok create = Oluştur confirm = Onayla revoke = İptal et diff --git a/crates/client/lang/tr/builder_voice.txt b/crates/client/lang/tr/builder_voice.txt index 2fd2b81..befc4e0 100644 --- a/crates/client/lang/tr/builder_voice.txt +++ b/crates/client/lang/tr/builder_voice.txt @@ -2,7 +2,6 @@ no_rooms = Aktif ses odası yok join = Katıl voice_on = Ses açık voice_off = Ses kapalı -no_users = Kullanıcı yok muted = Susturuldu ghost = Hayalet unmute = Sesi aç diff --git a/crates/client/lang/tr/camera_view.txt b/crates/client/lang/tr/camera_view.txt index 8214bf0..2e2e0f6 100644 --- a/crates/client/lang/tr/camera_view.txt +++ b/crates/client/lang/tr/camera_view.txt @@ -1,3 +1,2 @@ watch = İzle screens = ekran -more = {count} daha diff --git a/crates/client/lang/tr/chat.txt b/crates/client/lang/tr/chat.txt index 5d587ee..319dc10 100644 --- a/crates/client/lang/tr/chat.txt +++ b/crates/client/lang/tr/chat.txt @@ -47,8 +47,6 @@ grid = Izgara hide = Gizle stats = Bağlantı istatistikleri stats_hide = Bağlantı istatistiklerini gizle -online = Çevrimiçi -offline = Çevrimdışı new = Yeni edited = (düzenlendi) calls = {count} arama diff --git a/crates/client/lang/tr/common.txt b/crates/client/lang/tr/common.txt index 3e43f85..786cfad 100644 --- a/crates/client/lang/tr/common.txt +++ b/crates/client/lang/tr/common.txt @@ -18,3 +18,7 @@ year_stamp = %-d %b %Y, %H:%M day = %-d %b day_year = %-d %b %Y date = %-d %b %Y +more = {count} daha +messages = Mesajlar +no_users = Kullanıcı yok +no_bans = Yasak yok diff --git a/crates/client/lang/tr/community_card.txt b/crates/client/lang/tr/community_card.txt index eb70a0a..89f04a4 100644 --- a/crates/client/lang/tr/community_card.txt +++ b/crates/client/lang/tr/community_card.txt @@ -1,2 +1 @@ people = {members} üye · {online} çevrimiçi -more = {count} kişi daha diff --git a/crates/client/lang/tr/community_settings.txt b/crates/client/lang/tr/community_settings.txt index c763c16..1cd4e5f 100644 --- a/crates/client/lang/tr/community_settings.txt +++ b/crates/client/lang/tr/community_settings.txt @@ -13,7 +13,6 @@ on = Açık off = Kapalı view = Görüntüle unban = Yasağı kaldır -no_bans = Yasak yok no_logs = Kayıt yok someone = birisi created = {actor} topluluğu oluşturdu diff --git a/crates/client/lang/tr/message_actions.txt b/crates/client/lang/tr/message_actions.txt index 48bad60..952587d 100644 --- a/crates/client/lang/tr/message_actions.txt +++ b/crates/client/lang/tr/message_actions.txt @@ -10,4 +10,3 @@ confirm = Onayla delete = Sil send = Gönder people = Kişiler -messages = Mesajlar diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index d26f884..acf6b48 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -914,11 +914,9 @@ impl Yumush { palette: Palette, ) -> Div { let icon = community_icon(palette, community, size, font, &self.chat.avatars); - match &community.kind { - CommunityKind::Direct { peer } => { - presence_avatar(icon, self.presence_of(peer.id), size, palette) - } - CommunityKind::Group | CommunityKind::Notes => icon, + match community.kind.peer() { + Some(peer) => presence_avatar(icon, self.presence_of(peer.id), size, palette), + None => icon, } } @@ -933,6 +931,10 @@ impl Yumush { .unwrap_or(Presence::Offline) } + pub fn is_online(&self, user_id: Id) -> bool { + self.presence_of(user_id) != Presence::Offline + } + pub fn request_avatar(&mut self, avatar_id: Id, cx: &mut Context) { if self.chat.avatars.contains_key(&avatar_id) || self.chat.avatar_requests.contains(&avatar_id) @@ -1115,7 +1117,8 @@ impl Yumush { self.chat .communities() .iter() - .any(|community| community.id == community_id && community.kind.is_direct()) + .find(|community| community.id == community_id) + .is_some_and(|community| community.kind.is_direct()) } fn is_me(&self, user_id: Id) -> bool { diff --git a/crates/client/src/gui/builder.rs b/crates/client/src/gui/builder.rs index 982b4fa..5f0882f 100644 --- a/crates/client/src/gui/builder.rs +++ b/crates/client/src/gui/builder.rs @@ -17,7 +17,7 @@ use std::{fmt::Display, future::Future, path::PathBuf}; use common::{ call::{ListUsers, SetGhost}, - model::{CommunityKind, Member, Role}, + model::{Member, Role}, permission, }; use gpui_kit::{ @@ -90,7 +90,7 @@ impl BuilderTab { Self::Overview => w.overview, Self::Users => w.users, Self::Communities => w.communities, - Self::Messages => w.messages, + Self::Messages => crate::lang::w().common.messages, Self::Voice => w.voice, Self::Storage => w.storage, Self::Access => w.access, @@ -377,8 +377,7 @@ impl Yumush { .builder_communities .iter() .find(|summary| { - summary.community.kind == CommunityKind::Group - && summary.community.name.to_lowercase() == name + summary.community.kind.is_group() && summary.community.name.to_lowercase() == name }) .map(|summary| summary.community.id) } diff --git a/crates/client/src/gui/builder/access.rs b/crates/client/src/gui/builder/access.rs index 712f1ed..27573dd 100644 --- a/crates/client/src/gui/builder/access.rs +++ b/crates/client/src/gui/builder/access.rs @@ -279,13 +279,7 @@ impl Yumush { palette, ) .into_any_element(), - list_card( - ban_header, - bans.collect(), - w().builder_access.no_bans, - palette, - ) - .into_any_element(), + list_card(ban_header, bans.collect(), w().common.no_bans, palette).into_any_element(), ] } } diff --git a/crates/client/src/gui/builder/overview.rs b/crates/client/src/gui/builder/overview.rs index 19fc14e..41c24ca 100644 --- a/crates/client/src/gui/builder/overview.rs +++ b/crates/client/src/gui/builder/overview.rs @@ -192,7 +192,7 @@ impl Yumush { w().builder_overview.communities, overview.communities.to_string(), ), - (w().builder_overview.online, overview.online.to_string()), + (w().common.presence_online, overview.online.to_string()), (w().builder_overview.in_voice, overview.voice.to_string()), ( w().builder_overview.storage, @@ -216,7 +216,7 @@ impl Yumush { palette, )) .child(bar_chart( - w().builder_overview.messages, + w().common.messages, stats, |stat| stat.messages, messages, diff --git a/crates/client/src/gui/builder/ui.rs b/crates/client/src/gui/builder/ui.rs index e5a41e5..5920bf5 100644 --- a/crates/client/src/gui/builder/ui.rs +++ b/crates/client/src/gui/builder/ui.rs @@ -1,5 +1,9 @@ use crate::gui::style::{radius, size, space, text}; -use crate::gui::{Palette, Tooltip as _, clickable, text, widget}; +use crate::gui::{ + Palette, Tooltip as _, clickable, + parts::{self, Scale, Tone}, + text, +}; use crate::lang::w; use gpui_kit::{ AnyElement, App, Div, FontWeight, Hsla, IntoElement, ParentElement, Stateful, Styled, Window, @@ -47,7 +51,16 @@ pub(super) fn icon_button( palette: Palette, action: impl Fn(&mut Window, &mut App) + 'static, ) -> Stateful
{ - widget::icon_button(id, palette, icon, tip, action).text_color(color) + parts::icon_button( + id, + icon, + tip, + Tone::Idle, + Scale::Small, + palette.tokens, + action, + ) + .text_color(color) } pub(super) fn delete_icon_button( diff --git a/crates/client/src/gui/builder/users.rs b/crates/client/src/gui/builder/users.rs index 1c6dad6..e82c8f9 100644 --- a/crates/client/src/gui/builder/users.rs +++ b/crates/client/src/gui/builder/users.rs @@ -499,7 +499,7 @@ impl Yumush { )); let body = if rows.is_empty() { - super::ui::empty(w().builder_users.no_users, palette) + super::ui::empty(w().common.no_users, palette) } else { div().flex().flex_col().children(rows) }; diff --git a/crates/client/src/gui/builder/voice.rs b/crates/client/src/gui/builder/voice.rs index 9cb7851..3c68569 100644 --- a/crates/client/src/gui/builder/voice.rs +++ b/crates/client/src/gui/builder/voice.rs @@ -167,7 +167,7 @@ impl Yumush { card(palette) .child(card_header(&room.community, actions, palette)) - .child(rows_body(rows, w().builder_voice.no_users, palette)) + .child(rows_body(rows, w().common.no_users, palette)) } pub(super) fn voice_user_row( diff --git a/crates/client/src/gui/call_bar.rs b/crates/client/src/gui/call_bar.rs index a8b63a4..bf9aaee 100644 --- a/crates/client/src/gui/call_bar.rs +++ b/crates/client/src/gui/call_bar.rs @@ -8,7 +8,7 @@ use gpui_kit::{ use super::{ Tooltip as _, - parts::{Ink, Text, Tone, Voice, band, icon_button, thread, voice_line, words}, + parts::{Ink, Scale, Text, Tone, Voice, band, icon_button, thread, voice_line, words}, style::{Tokens, size, space}, }; use crate::lang::w; @@ -84,6 +84,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { w().call_bar.mute }, alarm(bar.muted), + Scale::Normal, t, run(&actions.mute), )) @@ -101,6 +102,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { w().call_bar.deafen }, alarm(bar.deafened), + Scale::Normal, t, run(&actions.deafen), )) @@ -115,6 +117,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { w().call_bar.turn_on_camera }, tone(bar.camera), + Scale::Normal, t, run(&actions.camera), )) @@ -128,6 +131,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { w().call_bar.share_screen }, tone(bar.screen), + Scale::Normal, t, run(&actions.screen), )) @@ -138,6 +142,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { IconName::PhoneOff, w().call_bar.leave_call, Tone::Danger, + Scale::Normal, t, run(&actions.leave), )); diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index c6fa093..81d37dc 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -311,13 +311,10 @@ impl Yumush { ) })) }) - .chain((more > 0).then(|| { - caption( - w().camera_view.more(more), - voice_line(None, Voice::Quiet, t), - t, - ) - })) + .chain( + (more > 0) + .then(|| caption(w().common.more(more), voice_line(None, Voice::Quiet, t), t)), + ) .collect() } diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index ca30efa..0eb0b8e 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -594,11 +594,11 @@ impl Chat { } pub(super) fn unread_groups(&self) -> Unread { - self.unread_where(|kind| matches!(kind, CommunityKind::Group)) + self.unread_where(|kind| kind.is_group()) } pub(super) fn unread_direct(&self) -> Unread { - self.unread_where(|kind| !matches!(kind, CommunityKind::Group)) + self.unread_where(|kind| !kind.is_group()) } pub fn focus(&self, window: &mut Window, cx: &mut Context) { @@ -1499,8 +1499,7 @@ impl Yumush { fn header(&self, entity: &Entity, palette: Palette) -> impl IntoElement { let community = self.chat.selected_community(); let name = community.map(community_name).unwrap_or_default(); - let group = - community.is_some_and(|community| matches!(community.kind, CommunityKind::Group)); + let group = community.is_some_and(|community| community.kind.is_group()); let voice = self.voice_toggle(entity, palette); let peer = community.and_then(|community| match &community.kind { CommunityKind::Direct { peer } => Some(self.chat.author(peer.id).unwrap_or(peer)), @@ -1576,7 +1575,7 @@ impl Yumush { ), super::Zoom::new( super::picture_of(community, &self.chat.avatars), - !matches!(community.kind, CommunityKind::Group), + !community.kind.is_group(), name.to_string(), ), ) @@ -2988,7 +2987,7 @@ fn members_column( let community_id = chat.selected_community_id?; let group = chat .selected_community() - .is_some_and(|community| matches!(community.kind, CommunityKind::Group)); + .is_some_and(|community| community.kind.is_group()); if !group { return None; } @@ -3122,15 +3121,11 @@ fn members_column( .flex() .flex_col() .child( - div() - .px(px(space::SM)) + super::parts::caption_head(format!("{title} · {total}"), palette.tokens) .pb(px(space::XS)) .flex() .items_center() .justify_between() - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(format!("{title} · {total}")) .children(action), ) .children(rows.into_iter().take(cap).map(row)) @@ -3152,7 +3147,7 @@ fn members_column( .rounded(px(radius::MD)) .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(w().community_card.more(more)), + .child(w().common.more(more)), ) }) }) @@ -3217,9 +3212,14 @@ fn members_column( .border_color(palette.border) .child(room_head(yumush, palette)) .children(call) - .children(section(w().chat.online, online, usize::MAX, None)) .children(section( - w().chat.offline, + w().common.presence_online, + online, + usize::MAX, + None, + )) + .children(section( + w().common.presence_offline, offline, if chat.offline_open { usize::MAX @@ -3238,7 +3238,7 @@ fn room_head(yumush: &Yumush, palette: Palette) -> Div { let online = chat .members .iter() - .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline) + .filter(|member| yumush.is_online(member.user.id)) .count(); div().px(px(space::SM)).child(super::parts::words( diff --git a/crates/client/src/gui/community_card.rs b/crates/client/src/gui/community_card.rs index cdb213a..ec40a1b 100644 --- a/crates/client/src/gui/community_card.rs +++ b/crates/client/src/gui/community_card.rs @@ -1,5 +1,5 @@ use common::{ - model::{Community, Id, Presence}, + model::{Community, Id}, permission, }; use gpui_kit::{ @@ -42,7 +42,7 @@ pub(super) fn community_popover( .chat .members .iter() - .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline) + .filter(|member| yumush.is_online(member.user.id)) .count(); super::parts::popover(t) .w(px(size::POPOVER)) diff --git a/crates/client/src/gui/community_settings.rs b/crates/client/src/gui/community_settings.rs index cc5295d..f19c34b 100644 --- a/crates/client/src/gui/community_settings.rs +++ b/crates/client/src/gui/community_settings.rs @@ -380,7 +380,7 @@ impl Yumush { Yumush::set_ban_sort, ), rows, - w().community_settings.no_bans, + w().common.no_bans, palette, )) }); diff --git a/crates/client/src/gui/composer.rs b/crates/client/src/gui/composer.rs index 8fe54c0..05ee0d0 100644 --- a/crates/client/src/gui/composer.rs +++ b/crates/client/src/gui/composer.rs @@ -1,6 +1,7 @@ +use super::parts::{Scale, Tone, icon_button}; use super::style::{radius, size, space, stroke, text}; use super::text; -use super::widget::{compact_field, icon_button, panel, spawn_done}; +use super::widget::{compact_field, panel, spawn_done}; use crate::gui::glyph::Fill as _; use common::model::Id; use std::time::{Duration, Instant}; @@ -184,9 +185,11 @@ fn cancel_button(entity: &Entity, palette: Palette) -> impl IntoElement icon_button( "cancel_composer", - palette, IconName::Close, w().composer.cancel, + Tone::Idle, + Scale::Small, + palette.tokens, move |window, cx| { entity.update(cx, |yumush, cx| yumush.cancel_composer(window, cx)); }, @@ -708,9 +711,11 @@ pub fn plus_popover(chat: &Chat, entity: &Entity, palette: Palette) -> i (options.len() > MINIMUM_POLL_OPTIONS && !trailing_blank).then(|| { icon_button( format!("poll_remove_{index}"), - palette, IconName::Close, w().composer.remove_option, + Tone::Idle, + Scale::Small, + palette.tokens, move |_, cx| { remove.update(cx, |yumush, cx| { yumush.remove_poll_option(index, cx) diff --git a/crates/client/src/gui/gallery.rs b/crates/client/src/gui/gallery.rs index 92cf7a7..921bfbe 100644 --- a/crates/client/src/gui/gallery.rs +++ b/crates/client/src/gui/gallery.rs @@ -8,7 +8,7 @@ use gpui_kit::{ use super::call_bar::{self, CallActions, CallBar}; use super::{ parts::{ - Fill, Ink, Press, Text, Tone, Voice, band, button, caption, chevron, column, grow, + Fill, Ink, Press, Scale, Text, Tone, Voice, band, button, caption, chevron, column, grow, icon_button, index_item, options, popover, row, section, spark, stack, strong, toggle, track, voice_line, words, }, @@ -235,6 +235,7 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement { IconName::Mic, "Mute", Tone::Idle, + Scale::Normal, t, |_, _| {}, )) @@ -244,6 +245,7 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement { IconName::Camera, "Camera", Tone::On, + Scale::Normal, t, |_, _| {}, )) @@ -253,6 +255,7 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement { IconName::PhoneOff, "Leave", Tone::Danger, + Scale::Normal, t, |_, _| {}, )), diff --git a/crates/client/src/gui/jump.rs b/crates/client/src/gui/jump.rs index e137da8..37afb6b 100644 --- a/crates/client/src/gui/jump.rs +++ b/crates/client/src/gui/jump.rs @@ -145,10 +145,7 @@ impl Yumush { .chat .communities .iter() - .filter_map(|community| match &community.kind { - CommunityKind::Direct { peer } => Some(peer.id), - _ => None, - }) + .filter_map(|community| community.kind.peer().map(|peer| peer.id)) .collect(); let mut seen = std::collections::HashSet::new(); let people = self diff --git a/crates/client/src/gui/media_view.rs b/crates/client/src/gui/media_view.rs index e856a9e..63deb10 100644 --- a/crates/client/src/gui/media_view.rs +++ b/crates/client/src/gui/media_view.rs @@ -642,16 +642,15 @@ fn icon_button( palette: Palette, on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> impl IntoElement { - clickable(id, palette, on_click) - .tip(tip) - .size(px(size::CONTROL)) - .flex_shrink_0() - .flex() - .items_center() - .justify_center() - .rounded(px(radius::MD)) - .text_color(palette.text) - .child(Icon::new(icon).size(px(size::ICON))) + super::parts::icon_button( + id, + icon, + tip, + super::parts::Tone::Idle, + super::parts::Scale::Normal, + palette.tokens, + on_click, + ) } fn file_view( diff --git a/crates/client/src/gui/message_actions.rs b/crates/client/src/gui/message_actions.rs index 0aa3c99..403d3a4 100644 --- a/crates/client/src/gui/message_actions.rs +++ b/crates/client/src/gui/message_actions.rs @@ -25,9 +25,11 @@ use super::{ chat::{Chat, ReportTarget}, clickable, composer::trigger_icon, - entity_action, millis_time, notify_error, primary_button, sidebar, + entity_action, millis_time, notify_error, + parts::{Scale, Tone, icon_button}, + primary_button, sidebar, style::{radius, size, space, text}, - widget::{field, icon_button, panel, search_text, spawn_done}, + widget::{field, panel, search_text, spawn_done}, }; pub fn reactions( @@ -324,11 +326,7 @@ pub fn search_popover(chat: &Chat, entity: &Entity, palette: Palette) -> .gap(px(space::XS)) .child(sidebar::input_box(&input, palette)) .children((!people.is_empty()).then(|| { - div() - .px(px(space::SM)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().message_actions.people) + super::parts::caption_head(w().message_actions.people, palette.tokens) })) .children(people.iter().map(|user| { person_row(user, &entity, &popover, palette) @@ -346,13 +344,10 @@ pub fn search_popover(chat: &Chat, entity: &Entity, palette: Palette) -> .child(user.username.clone()), ) })) - .children((!query.is_empty() && !hits.is_empty()).then(|| { - div() - .px(px(space::SM)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(w().message_actions.messages) - })) + .children( + (!query.is_empty() && !hits.is_empty()) + .then(|| super::parts::caption_head(w().common.messages, palette.tokens)), + ) .children(hits.iter().map(|hit| { jump_row("search_hit", hit, &entity, &popover, palette) .children(hit.time.as_ref().map(|time| { @@ -648,12 +643,13 @@ fn action( icon_button( format!("{name}_{message_id}"), - palette, icon, tip, + Tone::Idle, + Scale::Small, + palette.tokens, move |window, cx| { entity.update(cx, |yumush, cx| run(yumush, message_id, window, cx)); }, ) - .size(px(size::CONTROL_SM)) } diff --git a/crates/client/src/gui/parts.rs b/crates/client/src/gui/parts.rs index 1ae7f4f..36e17db 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -120,6 +120,10 @@ pub fn section(title: impl Into, t: Tokens) -> Div { .pb(px(space::XS)) } +pub fn caption_head(content: impl Into, t: Tokens) -> Div { + words(content, Text::Caption, Ink::Dim, t).px(px(space::SM)) +} + #[derive(Clone, Copy)] pub enum Fill { Part(f32), @@ -279,11 +283,18 @@ pub enum Tone { Danger, } +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum Scale { + Small, + Normal, +} + pub fn icon_button( id: impl Into, icon: IconName, tip: &'static str, tone: Tone, + scale: Scale, t: Tokens, on_click: impl Fn(&mut Window, &mut App) + 'static, ) -> Stateful
{ @@ -292,12 +303,16 @@ pub fn icon_button( Tone::On => (t.paper(), Some(t.press())), Tone::Danger => (t.bad(), None), }; + let (control, glyph) = match scale { + Scale::Small => (size::CONTROL_SM, size::ICON_SM), + Scale::Normal => (size::CONTROL, size::ICON), + }; let hov = t.hov(); div() .id(id) .tip(tip) .cursor_pointer() - .size(px(size::CONTROL)) + .size(px(control)) .flex_none() .flex() .items_center() @@ -307,7 +322,7 @@ pub fn icon_button( .hover(move |style| style.bg(hov)) .text_color(ink) .on_click(move |_, window, cx| on_click(window, cx)) - .child(Icon::new(icon).size(px(size::ICON))) + .child(Icon::new(icon).size(px(glyph))) } pub fn chevron_face(open: bool, t: Tokens) -> Div { diff --git a/crates/client/src/gui/poll.rs b/crates/client/src/gui/poll.rs index f20048f..3815d1c 100644 --- a/crates/client/src/gui/poll.rs +++ b/crates/client/src/gui/poll.rs @@ -13,9 +13,10 @@ use super::{ Palette, Tooltip as _, Trigger, Yumush, avatar, chat::Chat, clickable, hoverable, + parts::{Scale, Tone, icon_button}, style::{radius, size, space, text}, text, - widget::{icon_button, panel, spawn_done}, + widget::{panel, spawn_done}, }; pub fn voter_count(poll: &Poll) -> usize { @@ -346,9 +347,11 @@ pub fn poll_card( let close_entity = entity.clone(); icon_button( format!("poll_close_{close_id}"), - palette, IconName::CircleStop, w().poll.end_poll, + Tone::Idle, + Scale::Small, + palette.tokens, move |window, cx| { close_entity .update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx)); @@ -528,9 +531,11 @@ impl Yumush { })) .child(icon_button( "poll_banner_jump", - palette, IconName::ArrowUpRight, w().poll.jump_to_message, + Tone::Idle, + Scale::Small, + palette.tokens, move |window, cx| { jump.update(cx, |yumush, cx| { yumush.go_to_message(message_id, window, cx) @@ -628,10 +633,18 @@ fn page_button( palette: Palette, ) -> impl IntoElement { let entity = entity.clone(); - icon_button(id, palette, icon, tip, move |_, cx| { - entity.update(cx, |yumush, cx| { - yumush.chat.poll_page = yumush.chat.poll_page.wrapping_add(step); - cx.notify(); - }); - }) + icon_button( + id, + icon, + tip, + Tone::Idle, + Scale::Small, + palette.tokens, + move |_, cx| { + entity.update(cx, |yumush, cx| { + yumush.chat.poll_page = yumush.chat.poll_page.wrapping_add(step); + cx.notify(); + }); + }, + ) } diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index d650039..52822eb 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -26,7 +26,7 @@ use gpui_kit::{ use super::chat::{CardMenu, ReportTarget, View}; use super::message_actions::report_bar; -use super::parts::{Ink, Text, Tone, Voice, band, icon_button, stack, voice_line, words}; +use super::parts::{Ink, Scale, Text, Tone, Voice, band, icon_button, stack, voice_line, words}; use super::social::Relation; use super::style::{radius, size, space, stroke, text}; use super::widget::spawn_done; @@ -273,6 +273,7 @@ impl Card { IconName::Ellipsis, w().profile.more, Tone::Idle, + Scale::Normal, t, card_menu_action(entity, CardMenu::More), )) @@ -481,6 +482,7 @@ impl Card { }, w().profile.mute, Tone::Idle, + Scale::Normal, t, entity_action(entity, move |yumush, window, cx| { yumush.toggle_user_mute(user_id, window, cx) diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index b49b8d5..6b362d9 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -38,13 +38,13 @@ use super::{ clickable, entity_action, media_view::into_render_image, notify_error, - parts::{self, Tone, scrim}, + parts::{self, Scale, Tone, icon_button, scrim}, settings_page::segmented, stream_stats::{stream_card, watch_stats}, style::{radius, size, space, text}, surface::Surface, text, - widget::{icon_button, spawn_warn}, + widget::spawn_warn, }; use crate::{ settings::{self, ShareAudio, ShareCodec, ShareSettings}, @@ -820,6 +820,7 @@ impl Yumush { IconName::ChartBar, w().share_view.stream_stats, if viewer.stats { Tone::On } else { Tone::Idle }, + Scale::Normal, t, move |_, cx| { entity.update(cx, |yumush, cx| { @@ -865,7 +866,6 @@ impl Yumush { let muted = self.settings.share.volume == 0.; icon_button( format!("share_mute_{muted}"), - palette, if muted { IconName::VolumeX } else { @@ -876,6 +876,9 @@ impl Yumush { } else { w().share_view.mute }, + Tone::Idle, + Scale::Small, + palette.tokens, entity_action(entity, |yumush, window, cx| { yumush.toggle_share_mute(window, cx) }), @@ -888,16 +891,20 @@ impl Yumush { })) .child(icon_button( format!("share_fullscreen_{}", viewer.fullscreen), - palette, fullscreen_icon, fullscreen_tip, + Tone::Idle, + Scale::Small, + palette.tokens, entity_action(entity, |yumush, _, cx| yumush.toggle_fullscreen(cx)), )) .child(icon_button( "share_close".to_string(), - palette, IconName::X, w().share_view.close, + Tone::Idle, + Scale::Small, + palette.tokens, entity_action(entity, |yumush, _, cx| yumush.close_viewer(cx)), )), ), @@ -1139,13 +1146,7 @@ fn group(label: &'static str, rows: Vec, palette: Palette) -> .flex() .flex_col() .gap(px(space::XXS)) - .child( - div() - .px(px(space::SM)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(label), - ) + .child(parts::caption_head(label, palette.tokens)) .children(rows) } diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 8751cf8..3ba0c9e 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -26,11 +26,12 @@ use super::{ Palette, Tooltip as _, Yumush, avatar, chat::{View, create_community}, clickable, community_icon, community_name, entity_action, hoverable, input_dialog, + parts::{Scale, Tone, icon_button}, presence_avatar, profile::profile_popover, social::Relation, style::{radius, size, space, text}, - widget::{bare_input, compact_frame, icon_button}, + widget::{bare_input, compact_frame}, }; const SLIDE: std::time::Duration = std::time::Duration::from_millis(320); @@ -473,7 +474,7 @@ impl Yumush { }; let pins = self.rooms(entity, palette, |room| pinned.contains(&room.id)); let groups = self.rooms(entity, palette, |room| { - matches!(room.kind, CommunityKind::Group) && !pinned.contains(&room.id) + room.kind.is_group() && !pinned.contains(&room.id) }); let people = std::iter::once(self.notes_row(entity, palette)) .chain(self.rooms(entity, palette, |room| { @@ -534,7 +535,7 @@ impl Yumush { self.chat .opened .as_ref() - .filter(|opened| matches!(opened.kind, CommunityKind::Group)) + .filter(|opened| opened.kind.is_group()) .filter(|opened| !self.chat.joined(opened.id)), ) .filter(|community| !matches!(community.kind, CommunityKind::Notes)) @@ -561,7 +562,7 @@ impl Yumush { palette: Palette, ) -> AnyElement { let active = self.chat.is_selected(community.id); - let group = matches!(community.kind, CommunityKind::Group); + let group = community.kind.is_group(); let can_leave = group && (!active || permission::can_leave(self.actor_rank())); let muted = self.chat.muted.contains(&community.id); let unread = self.chat.unread.get(&community.id); @@ -889,9 +890,11 @@ impl Yumush { div().child( icon_button( "builder_button".to_string(), - palette, IconName::Ghost, w().sidebar.ghost_on, + Tone::Idle, + Scale::Small, + palette.tokens, entity_action(entity, |yumush, window, cx| { yumush.show_view(View::Builder, window, cx) }), @@ -1082,13 +1085,7 @@ fn group(title: &'static str, palette: Palette, rows: Vec) -> Option .flex() .flex_col() .gap(px(space::XXS)) - .child( - div() - .px(px(space::SM)) - .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(title), - ) + .child(super::parts::caption_head(title, palette.tokens)) .children(rows) }) } @@ -1164,9 +1161,11 @@ fn row_button( ) -> AnyElement { icon_button( format!("{key}_{id}"), - palette, icon, tip, + Tone::Idle, + Scale::Small, + palette.tokens, entity_action(entity, move |yumush, window, cx| { run(yumush, id, window, cx) }), diff --git a/crates/client/src/gui/social.rs b/crates/client/src/gui/social.rs index e8ae0d1..f1a4ea2 100644 --- a/crates/client/src/gui/social.rs +++ b/crates/client/src/gui/social.rs @@ -8,7 +8,7 @@ use common::{ ListFriends, ListInvitations, ListMembers, ListPresences, OpenDirect, OpenNotes, RemoveFriend, }, - model::{Community, CommunityKind, Rank, User}, + model::{Community, Rank, User}, validate::validate_username, }; use gpui_kit::{ @@ -107,10 +107,7 @@ impl Yumush { .chain( chat.communities .iter() - .filter_map(|community| match &community.kind { - CommunityKind::Direct { peer } => Some(peer), - CommunityKind::Group | CommunityKind::Notes => None, - }), + .filter_map(|community| community.kind.peer()), ); let avatar_ids: Vec = users .filter_map(|user| user.avatar_id) diff --git a/crates/client/src/gui/widget.rs b/crates/client/src/gui/widget.rs index 60ef349..73edc08 100644 --- a/crates/client/src/gui/widget.rs +++ b/crates/client/src/gui/widget.rs @@ -1,37 +1,16 @@ use std::{fmt::Display, future::Future}; use gpui_kit::{ - App, AsyncWindowContext, Context, Div, ElementId, Entity, ParentElement, Stateful, Styled, - WeakEntity, Window, - assets::IconName, - component::{Icon, input::Input, input::InputState}, + App, AsyncWindowContext, Context, Div, Entity, ParentElement, Styled, WeakEntity, Window, + component::{input::Input, input::InputState}, div, px, }; use super::{ - Palette, Tooltip as _, Yumush, clickable, notify_error, + Palette, Yumush, notify_error, style::{size, space}, }; -pub(super) fn icon_button( - id: impl Into, - palette: Palette, - icon: IconName, - tip: &'static str, - on_click: impl Fn(&mut Window, &mut App) + 'static, -) -> Stateful
{ - clickable(id, palette, on_click) - .tip(tip) - .size(px(size::CONTROL_SM)) - .flex_shrink_0() - .flex() - .items_center() - .justify_center() - .rounded_full() - .text_color(palette.muted) - .child(Icon::new(icon).size(px(size::ICON_SM))) -} - pub(super) fn panel(palette: Palette) -> Div { super::parts::surface(palette.tokens) } diff --git a/crates/common/src/model.rs b/crates/common/src/model.rs index ac03493..787db0e 100644 --- a/crates/common/src/model.rs +++ b/crates/common/src/model.rs @@ -131,9 +131,20 @@ pub enum CommunityKind { } impl CommunityKind { + pub fn is_group(&self) -> bool { + matches!(self, Self::Group) + } + pub fn is_direct(&self) -> bool { matches!(self, Self::Direct { .. }) } + + pub fn peer(&self) -> Option<&User> { + match self { + Self::Direct { peer } => Some(peer), + Self::Group | Self::Notes => None, + } + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)]