migrate ui components to gpui-kit
This commit is contained in:
@@ -4,12 +4,14 @@ use gpui::{
|
||||
AnyElement, App, Context, Div, Entity, InteractiveElement, IntoElement, ParentElement,
|
||||
Stateful, Styled, div, px,
|
||||
};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::component::avatar::Avatar;
|
||||
use gpui_kit::component::button::{Button, ButtonVariants};
|
||||
use gpui_kit::component::menu::DropdownMenu;
|
||||
use gpui_kit::component::{Disableable, Selectable, Sizable, h_flex};
|
||||
use nostr_sdk::prelude::*;
|
||||
use theme::TABBAR_HEIGHT;
|
||||
use ui::avatar::Avatar;
|
||||
use ui::button::{Button, ButtonVariants};
|
||||
use ui::menu::DropdownMenu;
|
||||
use ui::{Disableable, IconName, Selectable, Sizable, TRAFFIC_LIGHT_PADDING, h_flex};
|
||||
use ui::TABBAR_HEIGHT;
|
||||
use ui::TRAFFIC_LIGHT_PADDING;
|
||||
|
||||
use super::Sidebar;
|
||||
use crate::Command;
|
||||
@@ -23,7 +25,6 @@ impl Sidebar {
|
||||
let updater = AutoUpdater::try_global(cx);
|
||||
let profile = self.directory.read(cx).person(current_user, cx);
|
||||
let avatar = profile.avatar();
|
||||
let avatar_seed = profile.avatar_seed();
|
||||
|
||||
h_flex()
|
||||
.id("sidebar-user")
|
||||
@@ -31,29 +32,32 @@ impl Sidebar {
|
||||
.h(TABBAR_HEIGHT)
|
||||
.flex_shrink_0()
|
||||
.items_center()
|
||||
.gap(px(theme::SPACE))
|
||||
.gap(px(ui::SPACE))
|
||||
.px_2()
|
||||
.when(cfg!(target_os = "macos"), |this| {
|
||||
this.pl(px(TRAFFIC_LIGHT_PADDING))
|
||||
})
|
||||
.child(
|
||||
Button::new("current-user")
|
||||
.child(
|
||||
Avatar::new(avatar.clone())
|
||||
.seed(avatar_seed.clone())
|
||||
.small(),
|
||||
)
|
||||
.child(match avatar.clone() {
|
||||
Some(picture) => Avatar::new().src(picture).small().into_any_element(),
|
||||
None => Avatar::new().small().into_any_element(),
|
||||
})
|
||||
.small()
|
||||
.caret()
|
||||
.dropdown_caret(true)
|
||||
.compact()
|
||||
.transparent()
|
||||
.text()
|
||||
.dropdown_menu(move |this, _window, _cx| {
|
||||
this.menu_with_icon(
|
||||
"Profile",
|
||||
IconName::Profile,
|
||||
IconName::UserRound,
|
||||
Box::new(Command::ShowProfile),
|
||||
)
|
||||
.menu_with_icon("Relays", IconName::Relay, Box::new(Command::ShowRelayList))
|
||||
.menu_with_icon(
|
||||
"Relays",
|
||||
IconName::RadioTower,
|
||||
Box::new(Command::ShowRelayList),
|
||||
)
|
||||
.separator()
|
||||
.menu_with_icon(
|
||||
"Settings",
|
||||
@@ -79,7 +83,7 @@ impl Sidebar {
|
||||
)
|
||||
.child(
|
||||
Button::new("sidebar-new")
|
||||
.icon(IconName::PlusChat)
|
||||
.icon(IconName::MessageSquarePlus)
|
||||
.tooltip("New")
|
||||
.ghost()
|
||||
.small()
|
||||
@@ -87,18 +91,18 @@ impl Sidebar {
|
||||
menu.label("Public Group")
|
||||
.menu_with_icon(
|
||||
"New Group",
|
||||
IconName::Group,
|
||||
IconName::Users,
|
||||
Box::new(Command::NewGroup),
|
||||
)
|
||||
.menu_with_icon(
|
||||
"Join Group",
|
||||
IconName::Door,
|
||||
IconName::DoorOpen,
|
||||
Box::new(Command::JoinGroup),
|
||||
)
|
||||
.separator()
|
||||
.menu_with_icon(
|
||||
"New Chat",
|
||||
IconName::Message,
|
||||
IconName::MessageSquare,
|
||||
Box::new(Command::NewChat),
|
||||
)
|
||||
}),
|
||||
@@ -123,11 +127,11 @@ impl Sidebar {
|
||||
let staged = updater.read(cx).staged();
|
||||
|
||||
h_flex()
|
||||
.gap(px(theme::SPACE))
|
||||
.gap(px(ui::SPACE))
|
||||
.when(!up_to_date, |this| {
|
||||
this.child(
|
||||
Button::new("update")
|
||||
.icon(IconName::ArrowDownCircle)
|
||||
.icon(IconName::CircleArrowDown)
|
||||
.tooltip(status)
|
||||
.small()
|
||||
.ghost()
|
||||
@@ -137,7 +141,7 @@ impl Sidebar {
|
||||
.when(staged, |this| {
|
||||
this.child(
|
||||
Button::new("restart")
|
||||
.icon(IconName::ArrowDownCircle)
|
||||
.icon(IconName::CircleArrowDown)
|
||||
.tooltip("Quit and relaunch into the installed update")
|
||||
.small()
|
||||
.ghost()
|
||||
|
||||
Reference in New Issue
Block a user