chore: better dropdown menu #11

Merged
reya merged 2 commits from chore/improve-dropdown into master 2026-02-28 06:05:45 +00:00
Showing only changes of commit d6a2e748d0 - Show all commits

View File

@@ -503,54 +503,35 @@ impl Workspace {
.small()
.ghost()
.when(inbox_state.subscribing(), |this| this.indicator())
.dropdown_menu(move |this, _window, _cx| {
this.min_w(px(260.))
.label("Messaging Relays")
.menu_element_with_disabled(
Box::new(Command::ShowRelayList),
true,
move |_window, cx| {
.dropdown_menu(move |this, _window, cx| {
let persons = PersonRegistry::global(cx);
let profile = persons.read(cx).get(&pkey, cx);
let urls = profile.messaging_relays();
let urls: Vec<SharedString> = profile
.messaging_relays()
.iter()
.map(|url| SharedString::from(url.to_string()))
.collect();
v_flex()
.gap_1()
.w_full()
.items_start()
.justify_start()
.children({
let mut items = vec![];
// Header
let menu = this.min_w(px(260.)).label("Messaging Relays");
for url in urls.iter() {
items.push(
// Content
let menu = urls.into_iter().fold(menu, |this, url| {
this.item(PopupMenuItem::element(move |_window, _cx| {
h_flex()
.h_6()
.px_1()
.w_full()
.gap_2()
.px_2()
.text_xs()
.bg(cx
.theme()
.elevated_surface_background)
.rounded(cx.theme().radius)
.text_sm()
.child(
div()
.size_1()
.rounded_full()
.bg(gpui::green()),
div().size_1p5().rounded_full().bg(gpui::green()),
)
.child(SharedString::from(
url.to_string(),
)),
);
}
.child(url.clone())
}))
});
items
})
},
)
.separator()
// Footer
menu.separator()
.menu_with_icon(
"Reload",
IconName::Refresh,
@@ -591,51 +572,30 @@ impl Workspace {
.small()
.ghost()
.when(relay_list.configured(), |this| this.indicator())
.dropdown_menu(move |this, _window, _cx| {
this.min_w(px(260.))
.label("Relays")
.menu_element_with_disabled(
Box::new(Command::ShowRelayList),
true,
move |_window, cx| {
.dropdown_menu(move |this, _window, cx| {
let nostr = NostrRegistry::global(cx);
let urls = nostr.read(cx).read_only_relays(&pkey, cx);
v_flex()
.gap_1()
.w_full()
.items_start()
.justify_start()
.children({
let mut items = vec![];
// Header
let menu = this.min_w(px(260.)).label("Relays");
for url in urls.into_iter() {
items.push(
// Content
let menu = urls.into_iter().fold(menu, |this, url| {
this.item(PopupMenuItem::element(move |_window, _cx| {
h_flex()
.h_6()
.px_1()
.w_full()
.gap_2()
.px_2()
.text_xs()
.bg(cx
.theme()
.elevated_surface_background)
.rounded(cx.theme().radius)
.text_sm()
.child(
div()
.size_1()
.rounded_full()
.bg(gpui::green()),
div().size_1p5().rounded_full().bg(gpui::green()),
)
.child(url),
);
}
.child(url.clone())
}))
});
items
})
},
)
.separator()
// Footer
menu.separator()
.menu_with_icon(
"Reload",
IconName::Refresh,