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
+32 -28
View File
@@ -1,24 +1,25 @@
use gpui_kit::assets::IconName;
use gpui_kit::component::avatar::Avatar;
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::dock::{Panel, PanelEvent};
use gpui_kit::component::input::{Input, InputEvent, InputState};
use gpui_kit::component::scroll::ScrollableElement;
use gpui_kit::component::{ActiveTheme, Disableable, Sizable, WindowExt, h_flex, v_flex};
use std::collections::HashSet;
use anyhow::Error;
use gpui::prelude::FluentBuilder;
use gpui::{
AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
InteractiveElement, IntoElement, ParentElement, Render, SharedString, Styled, Subscription,
Task, TextAlign, Window, div, px, rems, retain_all,
App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement,
IntoElement, ParentElement, Render, SharedString, Styled, Subscription, Task, TextAlign,
Window, div, px, rems, retain_all,
};
use instant::Duration;
use nostr_sdk::prelude::*;
use person::Directory;
use smallvec::{SmallVec, smallvec};
use state::NostrRegistry;
use theme::{ActiveTheme, TextStyle, Typeset as _, button_radius, panel_radius};
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariants};
use ui::dock::{Panel, PanelEvent};
use ui::input::{Input, InputEvent, InputState};
use ui::scroll::ScrollableElement;
use ui::{Disableable, IconName, Sizable, StyledExt, WindowExtension, h_flex, v_flex};
use ui::{TextStyle, Typeset as _, button_radius, panel_radius};
pub fn init(window: &mut Window, cx: &mut App) -> Entity<ContactListPanel> {
cx.new(|cx| ContactListPanel::new(window, cx))
@@ -242,21 +243,22 @@ impl ContactListPanel {
.px_2()
.justify_between()
.rounded(px(button_radius()))
.hover(|this| this.bg(cx.theme().element_hover))
.hover(|this| this.bg(cx.theme().primary))
.child(
h_flex()
.gap(px(theme::SPACE))
.gap(px(ui::SPACE))
.text_style(TextStyle::Callout)
.child(
Avatar::new(profile.avatar())
.seed(profile.avatar_seed())
.small(),
)
.child(match profile.avatar() {
Some(picture) => {
Avatar::new().src(picture).small().into_any_element()
}
None => Avatar::new().small().into_any_element(),
})
.child(profile.name()),
)
.child(
Button::new("remove_{ix}")
.icon(IconName::Close)
.icon(IconName::X)
.xsmall()
.ghost()
.invisible()
@@ -288,13 +290,15 @@ impl ContactListPanel {
}
}
impl Panel for ContactListPanel {
fn panel_id(&self) -> SharedString {
self.name.clone()
impl gpui_kit::component::dock::BasePanel for ContactListPanel {
fn panel_name(&self) -> &'static str {
"Contacts"
}
}
fn title(&self, _cx: &App) -> AnyElement {
self.name.clone().into_any_element()
impl Panel for ContactListPanel {
fn title(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
self.name.clone()
}
}
@@ -316,15 +320,15 @@ impl Render for ContactListPanel {
.overflow_y_scrollbar()
.child(
v_flex()
.gap(px(theme::SPACE))
.gap(px(ui::SPACE))
.flex_1()
.w_full()
.text_style(TextStyle::Callout)
.child(
div()
.text_style(TextStyle::Caption)
.font_semibold()
.text_color(cx.theme().text_muted)
.font_weight(gpui::FontWeight::SEMIBOLD)
.text_color(cx.theme().muted_foreground)
.child("New contact:"),
)
.child(
@@ -371,10 +375,10 @@ impl Render for ContactListPanel {
})
.child(
Button::new("submit")
.icon(IconName::CheckCircle)
.icon(IconName::CircleCheck)
.label("Update")
.primary()
.font_semibold()
.font_weight(gpui::FontWeight::SEMIBOLD)
.loading(self.updating)
.disabled(self.updating)
.on_click(cx.listener(move |this, _ev, window, cx| {