This commit is contained in:
2026-10-23 11:06:34 +07:00
parent 1c00bc7956
commit e4ebe96077
10 changed files with 200 additions and 182 deletions
+1 -1
View File
@@ -338,7 +338,7 @@ impl NewChat {
Nav::new(start + offset)
.label(profile.name())
.text_xs()
.text_sm()
.when(!AppSettings::get_hide_avatar(cx), |this| {
this.prefix(
Avatar::new(profile.avatar())
+61 -61
View File
@@ -3,14 +3,14 @@ use gpui::prelude::FluentBuilder;
use gpui::{
App, AppContext, Context, Div, Entity, FocusHandle, InteractiveElement as _, IntoElement,
ParentElement, PathPromptOptions, Render, SharedString, StatefulInteractiveElement as _,
Styled, Subscription, Task, WeakEntity, Window, div, px, rems,
StyleRefinement, Styled, Subscription, Task, WeakEntity, Window, div, px, rems,
};
use gpui_base::{Popup, Select};
use gpui_kit::assets::IconName;
use gpui_kit::base::StyledExt as _;
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::dock::{DockArea, DockPlacement, PanelHandle};
use gpui_kit::component::form::field;
use gpui_kit::component::group_box::{GroupBox, GroupBoxVariants};
use gpui_kit::component::input::{Input, InputEvent, InputState, Textarea, TextareaState};
use gpui_kit::component::separator::Separator;
use gpui_kit::component::switch::Switch;
@@ -19,14 +19,14 @@ use nip29::{GroupCreateOptions, GroupKey, GroupsEvent, GroupsRegistry};
use nostr_sdk::prelude::*;
use settings::AppSettings;
use state::upload;
use ui::Avatar;
use ui::{Avatar, settings_row};
const DEFAULT_RELAYS: [&str; 2] = ["wss://relay.ditto.net", "wss://chat.wisp.talk"];
const PRIVATE_DESC: &str = "Only members can read group messages";
const CLOSED_DESC: &str = "Join requests are ignored (invite-only)";
const RESTRICTED_DESC: &str = "Only members can post messages";
const HIDDEN_DESC: &str = "Hidden from non-members, not discoverable";
const LIST_PRIVATE_DESC: &str = "Kept encrypted in your group list so others can't see you joined";
const LIST_PRIVATE_DESC: &str = "Kept encrypted in your group list so others can't see";
pub fn open(dock: WeakEntity<DockArea>, window: &mut Window, cx: &mut App) {
open_with(dock, None, window, cx);
@@ -462,71 +462,72 @@ impl NewGroup {
}
fn render_access(&self, cx: &mut Context<Self>) -> impl IntoElement {
let private = field().label("Private").description(PRIVATE_DESC).child(
Switch::new("private")
.checked(self.private)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.private = *checked;
cx.notify();
})),
);
let closed = field().label("Closed").description(CLOSED_DESC).child(
Switch::new("closed")
.checked(self.closed)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.closed = *checked;
cx.notify();
})),
);
let restricted = field()
.label("Restricted")
.description(RESTRICTED_DESC)
.child(
GroupBox::new()
.fill()
.title("Access settings")
.title_style(group_box_title_style(cx))
.child(settings_row(
"Private",
PRIVATE_DESC,
Switch::new("private")
.checked(self.private)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.private = *checked;
cx.notify();
})),
cx,
))
.child(settings_row(
"Closed",
CLOSED_DESC,
Switch::new("closed")
.checked(self.closed)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.closed = *checked;
cx.notify();
})),
cx,
))
.child(settings_row(
"Restricted",
RESTRICTED_DESC,
Switch::new("restricted")
.checked(self.restricted)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.restricted = *checked;
cx.notify();
})),
);
let hidden = field().label("Hidden").description(HIDDEN_DESC).child(
Switch::new("hidden")
.checked(self.hidden)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.hidden = *checked;
cx.notify();
})),
);
v_flex()
.gap_2()
.child(field_label("Access settings", cx))
.child(switch_row(private, cx))
.child(switch_row(closed, cx))
.child(switch_row(restricted, cx))
.child(switch_row(hidden, cx))
cx,
))
.child(settings_row(
"Hidden",
HIDDEN_DESC,
Switch::new("hidden")
.checked(self.hidden)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.hidden = *checked;
cx.notify();
})),
cx,
))
}
fn render_list_setting(&self, cx: &mut Context<Self>) -> impl IntoElement {
let list_private = field()
.label("Private on my list")
.description(LIST_PRIVATE_DESC)
.child(
GroupBox::new()
.fill()
.title("List")
.title_style(group_box_title_style(cx))
.child(settings_row(
"Private on my list",
LIST_PRIVATE_DESC,
Switch::new("list-private")
.checked(self.list_private)
.on_click(cx.listener(|this, checked: &bool, _window, cx| {
this.list_private = *checked;
cx.notify();
})),
);
v_flex()
.gap_2()
.child(field_label("List", cx))
.child(switch_row(list_private, cx))
cx,
))
}
fn render_error(
@@ -662,13 +663,12 @@ fn field_label(text: &'static str, cx: &App) -> Div {
.child(text)
}
fn switch_row(switch: impl IntoElement, cx: &App) -> Div {
div()
.w_full()
.p_2()
.rounded(cx.theme().radius)
.bg(cx.theme().secondary)
.child(switch)
/// Match [`field_label`]'s design for GroupBox titles.
fn group_box_title_style(cx: &App) -> StyleRefinement {
StyleRefinement::default()
.text_xs()
.text_color(cx.theme().muted_foreground)
.font_semibold()
}
fn relay_label(relay: &RelayUrl) -> SharedString {
+41 -37
View File
@@ -6,15 +6,14 @@ use gpui::{
use gpui_kit::assets::IconName;
use gpui_kit::base::StyledExt as _;
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::form::field;
use gpui_kit::component::group_box::{GroupBox, GroupBoxVariants};
use gpui_kit::component::input::{Input, InputState};
use gpui_kit::component::menu::{DropdownMenu, PopupMenuItem};
use gpui_kit::component::notification::Notification;
use gpui_kit::component::switch::Switch;
use gpui_kit::component::{ActiveTheme, Disableable, Sizable, WindowExt, h_flex, v_flex};
use settings::AppSettings;
use settings::AppearanceMode;
use settings::{AppSettings, AppearanceMode};
use ui::settings_row;
pub fn init(window: &mut Window, cx: &mut App) -> Entity<Preferences> {
cx.new(|cx| Preferences::new(window, cx))
@@ -114,28 +113,35 @@ impl Render for Preferences {
.id("general")
.title("General")
.fill()
.child(field().label("Screening").description(SCREENING).child(
.child(settings_row(
"Screening",
SCREENING,
Switch::new("screening").checked(screening).on_click(
move |_, _window, cx| {
AppSettings::update_screening(!screening, cx);
},
),
cx,
))
.child(
field().label("Web of Trust").description(WOT).child(
Switch::new("wot-auto-trust")
.checked(wot_auto_trust)
.on_click(move |_, _window, cx| {
AppSettings::update_wot_auto_trust(!wot_auto_trust, cx);
}),
),
)
.child(field().label("Hide user avatar").description(AVATAR).child(
.child(settings_row(
"Web of Trust",
WOT,
Switch::new("wot-auto-trust")
.checked(wot_auto_trust)
.on_click(move |_, _window, cx| {
AppSettings::update_wot_auto_trust(!wot_auto_trust, cx);
}),
cx,
))
.child(settings_row(
"Hide user avatar",
AVATAR,
Switch::new("avatar").checked(hide_avatar).on_click(
move |_, _window, cx| {
AppSettings::update_hide_avatar(!hide_avatar, cx);
},
),
cx,
)),
)
.child(
@@ -179,19 +185,17 @@ impl Render for Preferences {
.id("background")
.title("Background")
.fill()
.child(
field()
.label("Panel background")
.description(BACKGROUND)
.child(
Switch::new("panel-background")
.checked(panel_background)
.on_click(move |_, _window, cx| {
AppSettings::update_panel_background(!panel_background, cx);
cx.refresh_windows();
}),
),
)
.child(settings_row(
"Panel background",
BACKGROUND,
Switch::new("panel-background")
.checked(panel_background)
.on_click(move |_, _window, cx| {
AppSettings::update_panel_background(!panel_background, cx);
cx.refresh_windows();
}),
cx,
))
.child(
h_flex()
.gap_3()
@@ -245,16 +249,16 @@ impl Render for Preferences {
.id("experiments")
.title("Experiments")
.fill()
.child(
field()
.label("Decoupling Encryption Key")
.description(NIP4E)
.child(Switch::new("nip4e").checked(nip4e).on_click(
move |_, _window, cx| {
AppSettings::update_nip4e(!nip4e, cx);
},
)),
),
.child(settings_row(
"Decoupling Encryption Key",
NIP4E,
Switch::new("nip4e")
.checked(nip4e)
.on_click(move |_, _window, cx| {
AppSettings::update_nip4e(!nip4e, cx);
}),
cx,
)),
)
.child(
GroupBox::new()
+1 -1
View File
@@ -358,7 +358,7 @@ impl CoopTabGroupSkin {
this
} else {
this.text_color(cx.theme().tab_foreground)
.bg(cx.theme().tab)
.bg(cx.theme().list_hover)
}
})
.selected(active)
+3 -15
View File
@@ -87,22 +87,10 @@ impl Sidebar {
.small()
.dropdown_menu(|menu, _window, _cx| {
menu.label("Public Group")
.menu_with_icon(
"New Group",
IconName::Group,
Box::new(Command::NewGroup),
)
.menu_with_icon(
"Join Group",
IconName::Door,
Box::new(Command::JoinGroup),
)
.menu("New Group", Box::new(Command::NewGroup))
.menu("Join Group", Box::new(Command::JoinGroup))
.separator()
.menu_with_icon(
"New Chat",
IconName::Message,
Box::new(Command::NewChat),
)
.menu("New Chat", Box::new(Command::NewChat))
}),
)
.when(self.group_open, |this| {