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