migrate ui components to gpui-kit

This commit is contained in:
2026-10-21 13:40:29 +07:00
parent 0d4acf5b65
commit d0ad1a6f57
173 changed files with 2775 additions and 10885 deletions
+63 -38
View File
@@ -6,15 +6,16 @@ use gpui::{
AnyElement, App, AppContext, Entity, IntoElement, ParentElement, SharedString, Styled,
WeakEntity, Window, div, px,
};
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::dialog::DialogButtonProps;
use gpui_kit::component::form::field as form_field;
use gpui_kit::component::input::InputState;
use gpui_kit::component::notification::Notification;
use gpui_kit::component::switch::Switch;
use gpui_kit::component::{ActiveTheme, Sizable, WindowExt, h_flex, v_flex};
use nip29::{Group, GroupId, GroupMetadata};
use nostr_sdk::prelude::RelayUrl;
use theme::{ActiveTheme, TextStyle, Typeset as _};
use ui::button::{Button, ButtonVariants};
use ui::dialog::DialogButtonProps;
use ui::input::InputState;
use ui::notification::Notification;
use ui::switch::Switch;
use ui::{Sizable, WindowExtension, h_flex, v_flex};
use ui::{TextStyle, Typeset as _};
use crate::util::field;
@@ -99,13 +100,22 @@ pub(crate) fn open(group: WeakEntity<Group>, window: &mut Window, cx: &mut App)
let current = *flags.read(cx);
let supported = *livekit.read(cx) != Some(false);
this.confirm()
this.close_button(true)
.title("Edit Group")
.button_props(
DialogButtonProps::default()
.cancel_text("Cancel")
.ok_text("Save"),
)
.footer(
gpui_kit::component::dialog::DialogFooter::new().child(
gpui_kit::component::dialog::DialogAction::new().child(
gpui_kit::component::button::Button::new("save")
.label("Save")
.primary(),
),
),
)
.child(
v_flex()
.gap_3()
@@ -116,58 +126,73 @@ pub(crate) fn open(group: WeakEntity<Group>, window: &mut Window, cx: &mut App)
.child(children_section(&children, cx))
.child(
v_flex()
.gap(px(theme::SPACE))
.gap(px(ui::SPACE))
.child(
Switch::new("private")
form_field()
.label("Private")
.description("Only members can read group messages")
.checked(current.private)
.on_click(toggle(&flags, |flags| &mut flags.private)),
.child(
Switch::new("private")
.checked(current.private)
.on_click(toggle(&flags, |flags| &mut flags.private)),
),
)
.child(
Switch::new("restricted")
form_field()
.label("Restricted")
.description("Only members can post messages")
.checked(current.restricted)
.on_click(toggle(&flags, |flags| &mut flags.restricted)),
.child(
Switch::new("restricted")
.checked(current.restricted)
.on_click(toggle(&flags, |flags| {
&mut flags.restricted
})),
),
)
.child(
Switch::new("hidden")
form_field()
.label("Hidden")
.description("Hidden from non-members, not discoverable")
.checked(current.hidden)
.on_click(toggle(&flags, |flags| &mut flags.hidden)),
.child(
Switch::new("hidden")
.checked(current.hidden)
.on_click(toggle(&flags, |flags| &mut flags.hidden)),
),
)
.child(
Switch::new("closed")
form_field()
.label("Closed")
.description("Join requests are ignored (invite-only)")
.checked(current.closed)
.on_click(toggle(&flags, |flags| &mut flags.closed)),
.child(
Switch::new("closed")
.checked(current.closed)
.on_click(toggle(&flags, |flags| &mut flags.closed)),
),
)
.child(
Switch::new("livekit")
form_field()
.label("LiveKit")
.description(if supported {
"Announce audio and video support."
} else {
"The relay doesn't announce LiveKit support."
})
.checked(current.livekit)
.on_click({
let flags = flags.clone();
let livekit = livekit.clone();
.child(
Switch::new("livekit").checked(current.livekit).on_click({
let flags = flags.clone();
let livekit = livekit.clone();
move |next, _window, cx| {
if *next && *livekit.read(cx) == Some(false) {
return;
move |next, _window, cx| {
if *next && *livekit.read(cx) == Some(false) {
return;
}
flags.update(cx, |flags, cx| {
flags.livekit = *next;
cx.notify();
});
}
flags.update(cx, |flags, cx| {
flags.livekit = *next;
cx.notify();
});
}
}),
}),
),
),
),
)
@@ -263,14 +288,14 @@ fn children_section(children: &Entity<Vec<GroupId>>, cx: &App) -> AnyElement {
let mut section = v_flex()
.gap_1()
.text_style(TextStyle::Callout)
.text_color(cx.theme().text_muted)
.text_color(cx.theme().muted_foreground)
.child("Children");
if list.is_empty() {
return section
.child(
div()
.text_color(cx.theme().text_faint)
.text_color(cx.theme().muted_foreground)
.child("No subgroups"),
)
.into_any_element();
@@ -295,7 +320,7 @@ fn children_section(children: &Entity<Vec<GroupId>>, cx: &App) -> AnyElement {
div()
.min_w_0()
.truncate()
.text_color(cx.theme().text)
.text_color(cx.theme().foreground)
.child(SharedString::from(child.as_str().to_owned())),
)
.child(order),