feat: adopt the native OS theme (#66)
Reviewed-on: #66
This commit was merged in pull request #66.
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
use anyhow::Error;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle,
|
||||
Focusable, IntoElement, ParentElement, Render, SharedString, Styled, Task, Window, div, px,
|
||||
App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
IntoElement, ParentElement, Render, SharedString, Styled, Task, Window, div,
|
||||
};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::base::StyledExt as _;
|
||||
use gpui_kit::component::button::{Button, ButtonVariants};
|
||||
use gpui_kit::component::dock::{Panel, PanelEvent};
|
||||
use gpui_kit::component::input::{Input, InputState};
|
||||
use gpui_kit::component::separator::Separator;
|
||||
use gpui_kit::component::{ActiveTheme, Sizable, v_flex};
|
||||
use instant::Duration;
|
||||
use nostr_sdk::prelude::*;
|
||||
use state::USER_KEYRING;
|
||||
use theme::{ActiveTheme, TextStyle, Typeset as _};
|
||||
use ui::button::{Button, ButtonVariants};
|
||||
use ui::dock::{Panel, PanelEvent};
|
||||
use ui::input::{Input, InputState};
|
||||
use ui::{IconName, Sizable, StyledExt, divider, v_flex};
|
||||
|
||||
const MSG: &str = "Store your account keys in a safe location. \
|
||||
You can restore your account or move to another client anytime you want.";
|
||||
@@ -106,13 +108,15 @@ impl BackupPanel {
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for BackupPanel {
|
||||
fn panel_id(&self) -> SharedString {
|
||||
self.name.clone()
|
||||
impl gpui_kit::component::dock::BasePanel for BackupPanel {
|
||||
fn panel_name(&self) -> &'static str {
|
||||
"Backup"
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self, _cx: &App) -> AnyElement {
|
||||
self.name.clone().into_any_element()
|
||||
impl Panel for BackupPanel {
|
||||
fn title(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
self.name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,26 +136,26 @@ impl Render for BackupPanel {
|
||||
.w_full()
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(SharedString::from(MSG)),
|
||||
)
|
||||
.child(divider(cx))
|
||||
.child(Separator::horizontal())
|
||||
.child(
|
||||
v_flex()
|
||||
.gap(px(theme::SPACE))
|
||||
.gap_2()
|
||||
.flex_1()
|
||||
.w_full()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_xs()
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1p5()
|
||||
.w_full()
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(SharedString::from("Public Key:")),
|
||||
)
|
||||
.child(Input::new(&self.npub_input).small().disabled(true)),
|
||||
@@ -162,9 +166,9 @@ impl Render for BackupPanel {
|
||||
.w_full()
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(SharedString::from("Secret Key:")),
|
||||
)
|
||||
.child(Input::new(&self.nsec_input).small().disabled(true)),
|
||||
@@ -181,7 +185,6 @@ impl Render for BackupPanel {
|
||||
})
|
||||
.primary()
|
||||
.small()
|
||||
.font_semibold()
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.copy_secret(cx);
|
||||
})),
|
||||
|
||||
@@ -9,18 +9,19 @@ use gpui::{
|
||||
size, transparent_black,
|
||||
};
|
||||
use gpui_base::{VirtualListScrollHandle, v_virtual_list};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::base::StyledExt as _;
|
||||
use gpui_kit::component::button::{Button, ButtonVariants};
|
||||
use gpui_kit::component::dock::{DockArea, DockPlacement, Panel, PanelEvent, PanelHandle};
|
||||
use gpui_kit::component::input::{Input, InputEvent, InputState};
|
||||
use gpui_kit::component::notification::Notification;
|
||||
use gpui_kit::component::scroll::Scrollbar;
|
||||
use gpui_kit::component::{ActiveTheme, Icon, Sizable, WindowExt, h_flex, v_flex};
|
||||
use nip29::{Discovery, GroupCandidate, GroupKey, GroupsEvent, GroupsRegistry, Membership};
|
||||
use nostr_sdk::prelude::{RelayUrl, Timestamp};
|
||||
use settings::AppSettings;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use theme::{ActiveTheme, TextStyle, Typeset as _, button_radius, panel_radius};
|
||||
use ui::avatar::Avatar;
|
||||
use ui::button::{Button, ButtonVariants};
|
||||
use ui::dock::{DockArea, DockPlacement, Panel, PanelEvent, PanelHandle};
|
||||
use ui::input::{Input, InputEvent, InputState};
|
||||
use ui::notification::Notification;
|
||||
use ui::scroll::Scrollbar;
|
||||
use ui::{Icon, IconName, Sizable, StyledExt, WindowExtension, h_flex, v_flex};
|
||||
use ui::Avatar;
|
||||
|
||||
const TITLE: &str = "Browse";
|
||||
const INPUT_PLACEHOLDER: &str = "wss://relay.example.com";
|
||||
@@ -228,7 +229,7 @@ impl BrowsePanel {
|
||||
let registry = GroupsRegistry::global(cx);
|
||||
let group = registry.update(cx, |registry, cx| registry.open(key, cx));
|
||||
|
||||
ui::dock::add_panel_to(
|
||||
crate::dock::add_panel_to(
|
||||
dock,
|
||||
PanelHandle::new(nip29_ui::init(group, window, cx)),
|
||||
DockPlacement::Center,
|
||||
@@ -268,7 +269,7 @@ impl BrowsePanel {
|
||||
.min_w_0()
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.line_height(relative(1.2))
|
||||
.child("Public Groups"),
|
||||
@@ -276,8 +277,8 @@ impl BrowsePanel {
|
||||
.child(
|
||||
div()
|
||||
.truncate()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.map(|this| match &self.relay {
|
||||
Some(relay) => {
|
||||
this.child(SharedString::from(relay.as_str().to_owned()))
|
||||
@@ -294,14 +295,9 @@ impl BrowsePanel {
|
||||
.w_full()
|
||||
.max_w_64()
|
||||
.px_1()
|
||||
.rounded(px(button_radius()))
|
||||
.bg(cx.theme().surface)
|
||||
.child(
|
||||
Input::new(&self.input)
|
||||
.appearance(false)
|
||||
.small()
|
||||
.flex_1(),
|
||||
)
|
||||
.rounded(cx.theme().radius)
|
||||
.bg(cx.theme().sidebar)
|
||||
.child(Input::new(&self.input).appearance(false).flex_1())
|
||||
.child(
|
||||
Button::new("relay-browse")
|
||||
.icon(IconName::ArrowRight)
|
||||
@@ -313,6 +309,7 @@ impl BrowsePanel {
|
||||
})),
|
||||
),
|
||||
)
|
||||
.flex_shrink_0()
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -341,8 +338,9 @@ impl BrowsePanel {
|
||||
.children(pair.first().map(|card| self.render_card(card, cx)))
|
||||
.child(match pair.get(1) {
|
||||
Some(card) => self.render_card(card, cx),
|
||||
None => div().flex_1().into_any_element(),
|
||||
None => div().flex_1().flex_shrink_0().into_any_element(),
|
||||
})
|
||||
.flex_shrink_0()
|
||||
.into_any_element()
|
||||
}
|
||||
})
|
||||
@@ -374,28 +372,28 @@ impl BrowsePanel {
|
||||
.min_w_0()
|
||||
.h_full()
|
||||
.overflow_hidden()
|
||||
.rounded(px(panel_radius()))
|
||||
.rounded(cx.theme().radius_lg)
|
||||
.cursor_pointer()
|
||||
.border_1()
|
||||
.border_color(transparent_black())
|
||||
.bg(cx.theme().surface)
|
||||
.bg(cx.theme().sidebar)
|
||||
.hover(|this| {
|
||||
this.bg(cx.theme().surface_raised)
|
||||
.border_color(cx.theme().border_strong)
|
||||
this.bg(cx.theme().secondary)
|
||||
.border_color(cx.theme().border)
|
||||
})
|
||||
.child(
|
||||
v_flex()
|
||||
.flex_1()
|
||||
.min_h_0()
|
||||
.p_2()
|
||||
.gap(px(theme::SPACE))
|
||||
.gap_2()
|
||||
.child(
|
||||
h_flex()
|
||||
.w_full()
|
||||
.items_center()
|
||||
.gap(px(theme::SPACE))
|
||||
.gap_2()
|
||||
.when(!hide_avatar, |this| {
|
||||
this.child(Avatar::from_source(picture).seed(seed).flex_shrink_0())
|
||||
this.child(Avatar::new(picture).seed(seed).flex_shrink_0())
|
||||
})
|
||||
.child(
|
||||
v_flex()
|
||||
@@ -403,7 +401,7 @@ impl BrowsePanel {
|
||||
.min_w_0()
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_xs()
|
||||
.truncate()
|
||||
.font_semibold()
|
||||
.line_height(relative(1.2))
|
||||
@@ -412,8 +410,8 @@ impl BrowsePanel {
|
||||
.child(
|
||||
div()
|
||||
.truncate()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_faint)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(relay),
|
||||
),
|
||||
),
|
||||
@@ -421,8 +419,8 @@ impl BrowsePanel {
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.text_ellipsis()
|
||||
.line_clamp(2)
|
||||
.map(|this| {
|
||||
@@ -438,11 +436,11 @@ impl BrowsePanel {
|
||||
h_flex()
|
||||
.w_full()
|
||||
.gap_1p5()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(Icon::new(IconName::Book))
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_xs()
|
||||
.child(SharedString::from(format!("{members} members"))),
|
||||
),
|
||||
),
|
||||
@@ -454,19 +452,21 @@ impl BrowsePanel {
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for BrowsePanel {
|
||||
fn panel_id(&self) -> SharedString {
|
||||
TITLE.into()
|
||||
impl gpui_kit::component::dock::BasePanel for BrowsePanel {
|
||||
fn panel_name(&self) -> &'static str {
|
||||
"Browse"
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self, cx: &App) -> AnyElement {
|
||||
impl Panel for BrowsePanel {
|
||||
fn title(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_xs()
|
||||
.child(
|
||||
Icon::new(IconName::Compass)
|
||||
.small()
|
||||
.text_color(cx.theme().text_faint),
|
||||
.text_color(cx.theme().muted_foreground),
|
||||
)
|
||||
.child(TITLE)
|
||||
.into_any_element()
|
||||
@@ -542,8 +542,8 @@ fn notice(text: &'static str, cx: &App) -> AnyElement {
|
||||
h_flex()
|
||||
.size_full()
|
||||
.justify_center()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(text)
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -3,22 +3,23 @@ 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, rems, retain_all,
|
||||
};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::base::StyledExt as _;
|
||||
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 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::Avatar;
|
||||
|
||||
pub fn init(window: &mut Window, cx: &mut App) -> Entity<ContactListPanel> {
|
||||
cx.new(|cx| ContactListPanel::new(window, cx))
|
||||
@@ -241,12 +242,12 @@ impl ContactListPanel {
|
||||
.h_8()
|
||||
.px_2()
|
||||
.justify_between()
|
||||
.rounded(px(button_radius()))
|
||||
.hover(|this| this.bg(cx.theme().element_hover))
|
||||
.rounded(cx.theme().radius)
|
||||
.hover(|this| this.bg(cx.theme().primary))
|
||||
.child(
|
||||
h_flex()
|
||||
.gap(px(theme::SPACE))
|
||||
.text_style(TextStyle::Callout)
|
||||
.gap_2()
|
||||
.text_xs()
|
||||
.child(
|
||||
Avatar::new(profile.avatar())
|
||||
.seed(profile.avatar_seed())
|
||||
@@ -256,7 +257,7 @@ impl ContactListPanel {
|
||||
)
|
||||
.child(
|
||||
Button::new("remove_{ix}")
|
||||
.icon(IconName::Close)
|
||||
.icon(IconName::X)
|
||||
.xsmall()
|
||||
.ghost()
|
||||
.invisible()
|
||||
@@ -281,20 +282,22 @@ impl ContactListPanel {
|
||||
.border_2()
|
||||
.border_dashed()
|
||||
.border_color(cx.theme().border)
|
||||
.rounded(px(panel_radius()))
|
||||
.text_style(TextStyle::Callout)
|
||||
.rounded(cx.theme().radius_lg)
|
||||
.text_xs()
|
||||
.text_align(TextAlign::Center)
|
||||
.child(SharedString::from("Please add some relays."))
|
||||
}
|
||||
}
|
||||
|
||||
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 +319,15 @@ impl Render for ContactListPanel {
|
||||
.overflow_y_scrollbar()
|
||||
.child(
|
||||
v_flex()
|
||||
.gap(px(theme::SPACE))
|
||||
.gap_2()
|
||||
.flex_1()
|
||||
.w_full()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_xs()
|
||||
.child(
|
||||
div()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child("New contact:"),
|
||||
)
|
||||
.child(
|
||||
@@ -350,7 +353,7 @@ impl Render for ContactListPanel {
|
||||
this.child(
|
||||
div()
|
||||
.italic()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().danger)
|
||||
.child(error.clone()),
|
||||
)
|
||||
@@ -371,10 +374,9 @@ impl Render for ContactListPanel {
|
||||
})
|
||||
.child(
|
||||
Button::new("submit")
|
||||
.icon(IconName::CheckCircle)
|
||||
.icon(IconName::CircleCheck)
|
||||
.label("Update")
|
||||
.primary()
|
||||
.font_semibold()
|
||||
.loading(self.updating)
|
||||
.disabled(self.updating)
|
||||
.on_click(cx.listener(move |this, _ev, window, cx| {
|
||||
|
||||
@@ -7,22 +7,23 @@ use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
InteractiveElement, IntoElement, ParentElement, Render, SharedString,
|
||||
StatefulInteractiveElement, Styled, Subscription, Task, WeakEntity, Window, div, px, svg,
|
||||
StatefulInteractiveElement, Styled, Subscription, Task, WeakEntity, Window, div, svg,
|
||||
};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::base::StyledExt as _;
|
||||
use gpui_kit::component::button::{Button, ButtonVariants};
|
||||
use gpui_kit::component::dock::{DockArea, DockPlacement, Panel, PanelEvent, PanelHandle};
|
||||
use gpui_kit::component::scroll::ScrollableElement;
|
||||
use gpui_kit::component::{ActiveTheme, Icon, Sizable, h_flex, v_flex};
|
||||
use nostr_sdk::prelude::*;
|
||||
use person::PersonRegistry;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use state::{NostrRegistry, StateEvent};
|
||||
use theme::{ActiveTheme, TextStyle, Typeset as _, button_radius};
|
||||
use ui::avatar::Avatar;
|
||||
use ui::button::{Button, ButtonVariants};
|
||||
use ui::dock::{DockArea, DockPlacement, Panel, PanelEvent, PanelHandle, add_panel_to};
|
||||
use ui::group_box::{GroupBox, GroupBoxVariants};
|
||||
use ui::nav::Nav;
|
||||
use ui::scroll::ScrollableElement;
|
||||
use ui::{Icon, IconName, Sizable, StyledExt, h_flex, v_flex};
|
||||
use ui::Avatar;
|
||||
|
||||
use super::browse;
|
||||
use crate::dock::add_panel_to;
|
||||
use crate::nav::Nav;
|
||||
use crate::sidebar::open_room;
|
||||
|
||||
/// How many requests and follow ups to show per section.
|
||||
@@ -44,7 +45,6 @@ pub fn init(dock: WeakEntity<DockArea>, window: &mut Window, cx: &mut App) -> En
|
||||
}
|
||||
|
||||
pub struct GreeterPanel {
|
||||
name: SharedString,
|
||||
focus_handle: FocusHandle,
|
||||
dock: WeakEntity<DockArea>,
|
||||
|
||||
@@ -98,7 +98,6 @@ impl GreeterPanel {
|
||||
});
|
||||
|
||||
Self {
|
||||
name: "Onboarding".into(),
|
||||
focus_handle: cx.focus_handle(),
|
||||
dock,
|
||||
requests: vec![],
|
||||
@@ -205,9 +204,9 @@ impl GreeterPanel {
|
||||
.border_1()
|
||||
.border_dashed()
|
||||
.border_color(cx.theme().border)
|
||||
.rounded(px(button_radius()))
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_faint)
|
||||
.rounded(cx.theme().radius)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child("No chat requests")
|
||||
.into_any_element(),
|
||||
]
|
||||
@@ -219,7 +218,6 @@ impl GreeterPanel {
|
||||
let room = room.clone();
|
||||
let dock = dock.clone();
|
||||
let name = room.read(cx).display_name(cx);
|
||||
let picture = room.read(cx).display_image(cx);
|
||||
let seed = room.read(cx).display_image_seed(cx);
|
||||
let created_at = room.read(cx).created_at.to_ago();
|
||||
let preview = preview.clone();
|
||||
@@ -231,9 +229,9 @@ impl GreeterPanel {
|
||||
.h_9()
|
||||
.px_1p5()
|
||||
.gap_2()
|
||||
.rounded(px(button_radius()))
|
||||
.rounded(cx.theme().radius)
|
||||
.cursor_pointer()
|
||||
.hover(|this| this.bg(cx.theme().element_hover))
|
||||
.hover(|this| this.bg(cx.theme().list_hover))
|
||||
.on_click({
|
||||
let room = room.clone();
|
||||
let dock = dock.clone();
|
||||
@@ -242,25 +240,18 @@ impl GreeterPanel {
|
||||
}
|
||||
})
|
||||
.child(
|
||||
Avatar::from_source(picture)
|
||||
Avatar::new(room.read(cx).display_image(cx))
|
||||
.seed(seed)
|
||||
.small()
|
||||
.flex_shrink_0(),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.truncate()
|
||||
.text_style(TextStyle::Callout)
|
||||
.child(name),
|
||||
.small(),
|
||||
)
|
||||
.child(div().min_w_0().truncate().text_sm().child(name))
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.truncate()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_sm()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.italic()
|
||||
.child(preview),
|
||||
)
|
||||
@@ -283,8 +274,8 @@ impl GreeterPanel {
|
||||
.child(
|
||||
div()
|
||||
.text_align(gpui::TextAlign::Right)
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_faint)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(created_at),
|
||||
),
|
||||
)
|
||||
@@ -310,11 +301,24 @@ impl GreeterPanel {
|
||||
.collect()
|
||||
};
|
||||
|
||||
GroupBox::new()
|
||||
.id("requests")
|
||||
.title("Requests")
|
||||
.fill()
|
||||
.child(v_flex().gap_0().w_full().children(rows))
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.child("Requests"),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.rounded(cx.theme().radius_lg)
|
||||
.bg(cx.theme().group_box)
|
||||
.text_color(cx.theme().group_box_foreground)
|
||||
.children(rows),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -333,7 +337,6 @@ impl GreeterPanel {
|
||||
let room = room.clone();
|
||||
let dock = dock.clone();
|
||||
let name = room.read(cx).display_name(cx);
|
||||
let picture = room.read(cx).display_image(cx);
|
||||
let seed = room.read(cx).display_image_seed(cx);
|
||||
let created_at = room.read(cx).created_at.to_ago();
|
||||
let preview = preview.clone();
|
||||
@@ -345,9 +348,9 @@ impl GreeterPanel {
|
||||
.h_9()
|
||||
.px_1p5()
|
||||
.gap_2()
|
||||
.rounded(px(button_radius()))
|
||||
.rounded(cx.theme().radius)
|
||||
.cursor_pointer()
|
||||
.hover(|this| this.bg(cx.theme().element_hover))
|
||||
.hover(|this| this.bg(cx.theme().list_hover))
|
||||
.on_click({
|
||||
let room = room.clone();
|
||||
let dock = dock.clone();
|
||||
@@ -356,25 +359,18 @@ impl GreeterPanel {
|
||||
}
|
||||
})
|
||||
.child(
|
||||
Avatar::from_source(picture)
|
||||
Avatar::new(room.read(cx).display_image(cx))
|
||||
.seed(seed)
|
||||
.small()
|
||||
.flex_shrink_0(),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.truncate()
|
||||
.text_style(TextStyle::Callout)
|
||||
.child(name),
|
||||
.small(),
|
||||
)
|
||||
.child(div().min_w_0().truncate().text_sm().child(name))
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.truncate()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_sm()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.italic()
|
||||
.child(preview),
|
||||
)
|
||||
@@ -397,8 +393,8 @@ impl GreeterPanel {
|
||||
.child(
|
||||
div()
|
||||
.text_align(gpui::TextAlign::Right)
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_color(cx.theme().text_faint)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(created_at),
|
||||
),
|
||||
)
|
||||
@@ -424,11 +420,24 @@ impl GreeterPanel {
|
||||
.collect();
|
||||
|
||||
Some(
|
||||
GroupBox::new()
|
||||
.id("follow-ups")
|
||||
.title("Follow ups")
|
||||
.fill()
|
||||
.child(v_flex().gap_0().w_full().children(rows))
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.child("Follow ups"),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.px_2()
|
||||
.py_1()
|
||||
.rounded(cx.theme().radius_lg)
|
||||
.bg(cx.theme().group_box)
|
||||
.text_color(cx.theme().group_box_foreground)
|
||||
.children(rows),
|
||||
)
|
||||
.into_any_element(),
|
||||
)
|
||||
}
|
||||
@@ -439,8 +448,8 @@ impl GreeterPanel {
|
||||
.w_full()
|
||||
.child(
|
||||
div()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_style(TextStyle::Subheadline)
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.text_xs()
|
||||
.font_semibold()
|
||||
.child("Find new friends"),
|
||||
)
|
||||
@@ -449,13 +458,9 @@ impl GreeterPanel {
|
||||
.w_full()
|
||||
.child(
|
||||
Nav::new("browse-group")
|
||||
.prefix(
|
||||
Icon::new(IconName::Compass)
|
||||
.small()
|
||||
.text_color(cx.theme().text_faint),
|
||||
)
|
||||
.prefix(Icon::new(IconName::Compass))
|
||||
.label("Browse Public Groups")
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_sm()
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
let panel = browse::init(this.dock.clone(), window, cx);
|
||||
add_panel_to(
|
||||
@@ -469,9 +474,9 @@ impl GreeterPanel {
|
||||
)
|
||||
.child(
|
||||
Nav::new("browse-posts")
|
||||
.prefix(Icon::new(IconName::Link).small())
|
||||
.prefix(Icon::new(IconName::Link))
|
||||
.label("Browse Nostr via Jumble")
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_sm()
|
||||
.on_click(|_, _, cx| {
|
||||
cx.open_url(JUMBLE_URL);
|
||||
}),
|
||||
@@ -480,20 +485,22 @@ impl GreeterPanel {
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for GreeterPanel {
|
||||
fn panel_id(&self) -> SharedString {
|
||||
self.name.clone()
|
||||
impl gpui_kit::component::dock::BasePanel for GreeterPanel {
|
||||
fn panel_name(&self) -> &'static str {
|
||||
"Welcome"
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self, cx: &App) -> AnyElement {
|
||||
impl Panel for GreeterPanel {
|
||||
fn title(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.text_style(TextStyle::Caption)
|
||||
.text_xs()
|
||||
.child(
|
||||
svg()
|
||||
.path("brand/coop.svg")
|
||||
.size_4()
|
||||
.text_color(cx.theme().text_muted),
|
||||
.text_color(cx.theme().muted_foreground),
|
||||
)
|
||||
.child("Welcome")
|
||||
.into_any_element()
|
||||
@@ -520,7 +527,7 @@ impl Render for GreeterPanel {
|
||||
svg()
|
||||
.path("brand/coop.svg")
|
||||
.size_12()
|
||||
.text_color(cx.theme().text_faint),
|
||||
.text_color(cx.theme().muted_foreground),
|
||||
)
|
||||
})
|
||||
.when(logged_in, |this| {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
IntoElement, ParentElement, Render, SharedString, Styled, Window,
|
||||
App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, IntoElement,
|
||||
ParentElement, Render, SharedString, Styled, Window,
|
||||
};
|
||||
use theme::{ActiveTheme, TextStyle, Typeset as _};
|
||||
use ui::dock::{Panel, PanelEvent};
|
||||
use ui::{Icon, IconName, Sizable, h_flex};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::component::dock::{Panel, PanelEvent};
|
||||
use gpui_kit::component::{ActiveTheme, Icon, Sizable, h_flex};
|
||||
|
||||
pub fn init(window: &mut Window, cx: &mut App) -> Entity<InboxPanel> {
|
||||
cx.new(|cx| InboxPanel::new(window, cx))
|
||||
@@ -24,18 +24,20 @@ impl InboxPanel {
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for InboxPanel {
|
||||
fn panel_id(&self) -> SharedString {
|
||||
self.name.clone()
|
||||
impl gpui_kit::component::dock::BasePanel for InboxPanel {
|
||||
fn panel_name(&self) -> &'static str {
|
||||
"Inbox"
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self, cx: &App) -> AnyElement {
|
||||
impl Panel for InboxPanel {
|
||||
fn title(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
h_flex()
|
||||
.gap_1p5()
|
||||
.child(
|
||||
Icon::new(IconName::Inbox)
|
||||
.small()
|
||||
.text_color(cx.theme().text_faint),
|
||||
.text_color(cx.theme().muted_foreground),
|
||||
)
|
||||
.child(self.name.clone())
|
||||
.into_any_element()
|
||||
@@ -55,8 +57,8 @@ impl Render for InboxPanel {
|
||||
h_flex()
|
||||
.size_full()
|
||||
.justify_center()
|
||||
.text_style(TextStyle::Callout)
|
||||
.text_color(cx.theme().text_muted)
|
||||
.text_xs()
|
||||
.text_color(cx.theme().muted_foreground)
|
||||
.child(self.name.clone())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user