migrate ui components to gpui-kit
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::component::avatar::Avatar;
|
||||
use gpui_kit::component::button::{Button, ButtonVariants};
|
||||
use gpui_kit::component::dock::DockPlacement;
|
||||
use gpui_kit::component::input::{Input, InputState, Textarea, TextareaState};
|
||||
use gpui_kit::component::notification::Notification;
|
||||
use gpui_kit::component::{ActiveTheme, Disableable, Sizable, WindowExt, h_flex, v_flex};
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Error;
|
||||
@@ -12,13 +19,7 @@ use nostr_sdk::prelude::*;
|
||||
use person::{Directory, Person, PersonRegistry, shorten_pubkey};
|
||||
use settings::AppSettings;
|
||||
use state::{NostrRegistry, upload};
|
||||
use theme::{ActiveTheme, TextStyle, Typeset as _, button_radius};
|
||||
use ui::avatar::Avatar;
|
||||
use ui::button::{Button, ButtonVariants, IconPosition};
|
||||
use ui::dock::DockPlacement;
|
||||
use ui::input::{Input, InputState, Textarea, TextareaState};
|
||||
use ui::notification::Notification;
|
||||
use ui::{Disableable, IconName, Sizable, StyledExt, WindowExtension, h_flex, v_flex};
|
||||
use ui::{TextStyle, Typeset as _, button_radius};
|
||||
|
||||
use crate::Workspace;
|
||||
|
||||
@@ -372,17 +373,18 @@ impl Render for ProfileDialog {
|
||||
.w_full()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.bg(cx.theme().surface)
|
||||
.child(Avatar::new(avatar).seed(profile.avatar_seed()).large())
|
||||
.bg(cx.theme().sidebar)
|
||||
.child(match avatar {
|
||||
Some(picture) => Avatar::new().src(picture).large().into_any_element(),
|
||||
None => Avatar::new().large().into_any_element(),
|
||||
})
|
||||
.when(self.editing, |this| {
|
||||
this.child(
|
||||
Button::new("upload")
|
||||
.icon(IconName::ArrowRight)
|
||||
.icon_position(IconPosition::End)
|
||||
.label("Add an avatar")
|
||||
.xsmall()
|
||||
.ghost()
|
||||
.rounded()
|
||||
.disabled(self.uploading)
|
||||
.loading(self.uploading)
|
||||
.on_click(cx.listener(move |this, _, window, cx| {
|
||||
@@ -399,14 +401,14 @@ impl Render for ProfileDialog {
|
||||
.justify_center()
|
||||
.gap_3()
|
||||
.rounded(px(button_radius()))
|
||||
.bg(cx.theme().surface)
|
||||
.bg(cx.theme().sidebar)
|
||||
.text_style(TextStyle::Callout)
|
||||
.child(shorten_pkey)
|
||||
.child(
|
||||
Button::new("copy")
|
||||
.icon({
|
||||
if self.copied {
|
||||
IconName::CheckCircle
|
||||
IconName::CircleCheck
|
||||
} else {
|
||||
IconName::Copy
|
||||
}
|
||||
@@ -485,11 +487,10 @@ impl Render for ProfileDialog {
|
||||
.when(self.is_current_user && !self.editing, |this| {
|
||||
this.child(
|
||||
Button::new("update")
|
||||
.icon(IconName::Edit)
|
||||
.icon_position(IconPosition::End)
|
||||
.icon(IconName::SquarePen)
|
||||
.label("Update")
|
||||
.primary()
|
||||
.font_semibold()
|
||||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||||
.on_click(cx.listener(move |this, _ev, window, cx| {
|
||||
this.toggle_edit(window, cx);
|
||||
})),
|
||||
@@ -498,11 +499,10 @@ impl Render for ProfileDialog {
|
||||
.when(!self.is_current_user, |this| {
|
||||
this.child(
|
||||
Button::new("message")
|
||||
.icon(IconName::Message)
|
||||
.icon_position(IconPosition::End)
|
||||
.icon(IconName::MessageSquare)
|
||||
.label("Message")
|
||||
.primary()
|
||||
.font_semibold()
|
||||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||||
.on_click(cx.listener(move |this, _ev, window, cx| {
|
||||
this.message(window, cx);
|
||||
})),
|
||||
@@ -520,11 +520,10 @@ impl Render for ProfileDialog {
|
||||
)
|
||||
.child(
|
||||
Button::new("save")
|
||||
.icon(IconName::CheckCircle)
|
||||
.icon_position(IconPosition::End)
|
||||
.icon(IconName::CircleCheck)
|
||||
.label("Save")
|
||||
.primary()
|
||||
.font_semibold()
|
||||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||||
.loading(self.updating)
|
||||
.disabled(self.updating)
|
||||
.on_click(cx.listener(move |this, _ev, window, cx| {
|
||||
@@ -539,8 +538,8 @@ impl Render for ProfileDialog {
|
||||
fn label(label: &'static str, cx: &App) -> Div {
|
||||
div()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.font_semibold()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||||
.child(label)
|
||||
}
|
||||
|
||||
@@ -551,8 +550,8 @@ fn field(
|
||||
cx: &App,
|
||||
) -> Div {
|
||||
let (content, color) = match value {
|
||||
Some(value) => (value, cx.theme().text),
|
||||
None => (SharedString::from(placeholder), cx.theme().text_muted),
|
||||
Some(value) => (value, cx.theme().foreground),
|
||||
None => (SharedString::from(placeholder), cx.theme().muted_foreground),
|
||||
};
|
||||
|
||||
v_flex().gap_1p5().child(label(text, cx)).child(
|
||||
|
||||
Reference in New Issue
Block a user