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
+1 -1
View File
@@ -8,7 +8,7 @@ publish.workspace = true
state = { path = "../state" }
person = { path = "../person" }
ui = { path = "../ui" }
theme = { path = "../theme" }
gpui-kit.workspace = true
settings = { path = "../settings" }
gpui.workspace = true
+26 -24
View File
@@ -1,3 +1,4 @@
use gpui_kit::component::{ActiveTheme, Disableable, Sizable, WindowExt, h_flex, v_flex};
use std::cell::Cell;
use std::collections::HashSet;
use std::path::PathBuf;
@@ -10,16 +11,15 @@ use gpui::{
App, AppContext, Context, Entity, EventEmitter, Global, IntoElement, ParentElement,
SharedString, Styled, Subscription, Task, Window, div, px, relative,
};
use gpui_kit::component::avatar::Avatar;
use gpui_kit::component::button::Button;
use gpui_kit::component::notification::{Notification, NotificationType};
use nostr_sdk::prelude::*;
use person::Directory;
use settings::AppSettings;
use smallvec::{SmallVec, smallvec};
use state::{Announcement, CLIENT_NAME, NostrRegistry, UniversalSigner};
use theme::{ActiveTheme, TextStyle, Typeset as _, control_radius};
use ui::avatar::Avatar;
use ui::button::Button;
use ui::notification::{Notification, NotificationKind};
use ui::{Disableable, Sizable, StyledExt, WindowExtension, h_flex, v_flex};
use ui::{TextStyle, Typeset as _, control_radius};
const IDENTIFIER: &str = "coop:device";
@@ -599,7 +599,6 @@ impl DeviceRegistry {
// Get user's write relays
let event = event.clone();
let id: SharedString = event.id.to_hex().into();
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
// Get device keys
@@ -645,7 +644,7 @@ impl DeviceRegistry {
})?;
cx.update(|window, cx| {
window.clear_notification_by_id::<DeviceNotification>(id, cx);
window.remove_notification::<DeviceNotification>(cx);
})
.ok();
}
@@ -718,18 +717,17 @@ impl DeviceRegistry {
let entity = cx.entity().downgrade();
let loading = Rc::new(Cell::new(false));
let key = SharedString::from(event.id.to_hex());
Ok(Notification::new()
.type_id::<DeviceNotification>(key)
.id::<DeviceNotification>()
.autohide(false)
.with_kind(NotificationKind::Info)
.with_type(NotificationType::Info)
.title("Encryption Key Request")
.content(move |_this, _window, cx| {
let profile = directory.read(cx).person(&requester, cx);
v_flex()
.gap(px(theme::SPACE))
.gap(px(ui::SPACE))
.text_style(TextStyle::Callout)
.child(
div()
@@ -739,16 +737,16 @@ impl DeviceRegistry {
)
.child(
v_flex()
.gap(px(theme::SPACE))
.gap(px(ui::SPACE))
.child(
v_flex()
.gap_1()
.text_style(TextStyle::Callout)
.child(
div()
.font_semibold()
.font_weight(gpui::FontWeight::SEMIBOLD)
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_muted)
.text_color(cx.theme().muted_foreground)
.child(SharedString::from("From:")),
)
.child(
@@ -757,15 +755,19 @@ impl DeviceRegistry {
.w_full()
.px_2()
.rounded(px(control_radius()))
.bg(cx.theme().surface_card)
.bg(cx.theme().muted)
.child(
h_flex()
.gap(px(theme::SPACE))
.child(
Avatar::new(profile.avatar())
.seed(profile.avatar_seed())
.xsmall(),
)
.gap(px(ui::SPACE))
.child(match profile.avatar() {
Some(picture) => Avatar::new()
.src(picture)
.xsmall()
.into_any_element(),
None => Avatar::new()
.xsmall()
.into_any_element(),
})
.child(profile.name()),
),
),
@@ -776,9 +778,9 @@ impl DeviceRegistry {
.text_style(TextStyle::Callout)
.child(
div()
.font_semibold()
.font_weight(gpui::FontWeight::SEMIBOLD)
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_muted)
.text_color(cx.theme().muted_foreground)
.child(SharedString::from("Code:")),
)
.child(
@@ -787,7 +789,7 @@ impl DeviceRegistry {
.w_full()
.px_2()
.rounded(px(control_radius()))
.bg(cx.theme().surface_card)
.bg(cx.theme().muted)
.child(code_label.clone()),
),
),