notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 813b92a414b9e5ca4997d6bc68a4b37411610157
parent 6d426cf2c4731fca98cd37547d8d291b5047d037
Author: kernelkind <kernelkind@gmail.com>
Date:   Sun,  5 Oct 2025 15:35:55 -0400

ui: add `ProfileContextWidget`

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Acrates/notedeck_ui/src/profile/context.rs | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/notedeck_ui/src/profile/mod.rs | 1+
2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck_ui/src/profile/context.rs b/crates/notedeck_ui/src/profile/context.rs @@ -0,0 +1,52 @@ +use enostr::Pubkey; +use notedeck::{tr, Localization, ProfileContextSelection}; + +use crate::context_menu::{context_button, stationary_arbitrary_menu_button}; + +pub struct ProfileContextWidget { + place_at: egui::Rect, +} + +impl ProfileContextWidget { + pub fn new(place_at: egui::Rect) -> Self { + Self { place_at } + } + + pub fn context_button(&self, ui: &mut egui::Ui, pubkey: &Pubkey) -> egui::Response { + let painter = ui.painter_at(self.place_at); + + painter.circle_filled( + self.place_at.center(), + self.place_at.width() / 2.0, + ui.visuals().window_fill, + ); + + context_button(ui, ui.id().with(pubkey), self.place_at.shrink(4.0)) + } + + pub fn context_menu( + ui: &mut egui::Ui, + i18n: &mut Localization, + button_response: egui::Response, + ) -> Option<ProfileContextSelection> { + let mut context_selection: Option<ProfileContextSelection> = None; + + stationary_arbitrary_menu_button(ui, button_response, |ui| { + ui.set_max_width(100.0); + + if ui + .button(tr!( + i18n, + "Copy Link", + "Copy a damus.io link to the author's profile to keyboard" + )) + .clicked() + { + context_selection = Some(ProfileContextSelection::CopyLink); + ui.close_menu(); + } + }); + + context_selection + } +} diff --git a/crates/notedeck_ui/src/profile/mod.rs b/crates/notedeck_ui/src/profile/mod.rs @@ -1,5 +1,6 @@ use nostrdb::ProfileRecord; +pub mod context; pub mod name; pub mod picture; pub mod preview;