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
+21 -25
View File
@@ -1,3 +1,10 @@
use crate::nav::Nav;
use gpui_kit::assets::IconName;
use gpui_kit::component::avatar::Avatar;
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::dock::{DockArea, DockPlacement, PanelHandle};
use gpui_kit::component::input::{Input, InputEvent, InputState};
use gpui_kit::component::{ActiveTheme, Disableable, Sizable, WindowExt, h_flex, v_flex};
use std::ops::Range;
use std::rc::Rc;
@@ -13,13 +20,7 @@ use nostr_sdk::prelude::*;
use person::Directory;
use settings::AppSettings;
use state::NostrRegistry;
use theme::{ActiveTheme, TextStyle, Typeset as _};
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariants, IconPosition};
use ui::dock::{DockArea, DockPlacement, PanelHandle};
use ui::input::{Input, InputEvent, InputState};
use ui::nav::Nav;
use ui::{Disableable, IconName, Sizable, StyledExt, WindowExtension, h_flex, v_flex};
use ui::{TextStyle, Typeset as _};
/// Maximum number of members a chat can have.
const MAX_MEMBERS: usize = 3;
@@ -301,7 +302,7 @@ impl NewChat {
room
});
ui::dock::add_panel_to(
crate::dock::add_panel_to(
&self.dock,
PanelHandle::new(chat_ui::init(room.downgrade(), window, cx)),
DockPlacement::Center,
@@ -338,12 +339,10 @@ impl NewChat {
.label(profile.name())
.text_style(TextStyle::Callout)
.when(!AppSettings::get_hide_avatar(cx), |this| {
this.prefix(
Avatar::from_source(profile.avatar())
.seed(profile.avatar_seed())
.small()
.flex_shrink_0(),
)
this.prefix(match profile.avatar() {
Some(picture) => Avatar::new().src(picture).small().into_any_element(),
None => Avatar::new().small().flex_shrink_0().into_any_element(),
})
})
.on_click(cx.listener(move |this, _event, _window, cx| {
this.toggle_member(&public_key, cx);
@@ -367,15 +366,13 @@ impl NewChat {
.gap_1()
.p_0p5()
.rounded_full()
.bg(cx.theme().surface_raised)
.bg(cx.theme().secondary)
.text_style(TextStyle::Caption2)
.hover(|this| this.bg(cx.theme().element_hover))
.child(
Avatar::from_source(profile.avatar())
.seed(profile.avatar_seed())
.xsmall()
.flex_shrink_0(),
)
.hover(|this| this.bg(cx.theme().primary))
.child(match profile.avatar() {
Some(picture) => Avatar::new().src(picture).xsmall().into_any_element(),
None => Avatar::new().xsmall().flex_shrink_0().into_any_element(),
})
.child(div().max_w_32().truncate().child(profile.name()))
.on_click(cx.listener(move |this, _event, _window, cx| {
this.toggle_member(&public_key, cx);
@@ -424,7 +421,7 @@ impl Render for NewChat {
this.child(
div()
.text_style(TextStyle::Caption)
.text_color(cx.theme().text_faint)
.text_color(cx.theme().muted_foreground)
.child(notice),
)
}
@@ -452,10 +449,9 @@ impl Render for NewChat {
.child(
Button::new("start")
.icon(IconName::ArrowRight)
.icon_position(IconPosition::End)
.label("Start")
.primary()
.font_semibold()
.font_weight(gpui::FontWeight::SEMIBOLD)
.on_click(cx.listener(move |this, _event, window, cx| {
if this.start_chat(window, cx) {
window.close_dialog(cx);