diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs index 168686b..fe7867b 100644 --- a/crates/notedeck_columns/src/nav.rs +++ b/crates/notedeck_columns/src/nav.rs @@ -505,7 +505,7 @@ fn process_render_nav_action( } } RenderNavAction::ProfileAction(profile_action) => { - profile_action.process_profile_action(ctx.ndb, ctx.pool, ctx.accounts) + profile_action.process_profile_action(ui.ctx(), ctx.ndb, ctx.pool, ctx.accounts) } RenderNavAction::WalletAction(wallet_action) => { wallet_action.process(ctx.accounts, ctx.global_wallet) diff --git a/crates/notedeck_columns/src/profile.rs b/crates/notedeck_columns/src/profile.rs index ed4b934..901c33d 100644 --- a/crates/notedeck_columns/src/profile.rs +++ b/crates/notedeck_columns/src/profile.rs @@ -1,7 +1,7 @@ use enostr::{FilledKeypair, FullKeypair, ProfileState, Pubkey, RelayPool}; use nostrdb::{Ndb, Note, NoteBuildOptions, NoteBuilder, Transaction}; -use notedeck::{Accounts, ContactState}; +use notedeck::{Accounts, ContactState, ProfileContext}; use tracing::info; use crate::{nav::RouterAction, route::Route}; @@ -38,11 +38,13 @@ pub enum ProfileAction { SaveChanges(SaveProfileChanges), Follow(Pubkey), Unfollow(Pubkey), + Context(ProfileContext), } impl ProfileAction { pub fn process_profile_action( &self, + ctx: &egui::Context, ndb: &Ndb, pool: &mut RelayPool, accounts: &Accounts, @@ -77,6 +79,12 @@ impl ProfileAction { Self::send_unfollow_user_event(ndb, pool, accounts, target_key); None } + ProfileAction::Context(profile_context) => { + profile_context + .selection + .process(ctx, &profile_context.profile); + None + } } } diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs index 8b358a1..386259f 100644 --- a/crates/notedeck_columns/src/timeline/route.rs +++ b/crates/notedeck_columns/src/timeline/route.rs @@ -129,5 +129,8 @@ pub fn render_profile_route( ui::profile::ProfileViewAction::Unfollow(target_key) => Some( RenderNavAction::ProfileAction(ProfileAction::Unfollow(target_key)), ), + ui::profile::ProfileViewAction::Context(profile_context_selection) => Some( + RenderNavAction::ProfileAction(ProfileAction::Context(profile_context_selection)), + ), }) } diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs index f0aef99..7fc3003 100644 --- a/crates/notedeck_columns/src/ui/profile/mod.rs +++ b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -4,8 +4,8 @@ pub use edit::EditProfileView; use egui::{vec2, Color32, CornerRadius, Layout, Rect, RichText, ScrollArea, Sense, Stroke}; use enostr::Pubkey; use nostrdb::{ProfileRecord, Transaction}; -use notedeck::{tr, Localization}; -use notedeck_ui::profile::follow_button; +use notedeck::{tr, Localization, ProfileContext}; +use notedeck_ui::profile::{context::ProfileContextWidget, follow_button}; use robius_open::Uri; use tracing::error; @@ -38,6 +38,7 @@ pub enum ProfileViewAction { Note(NoteAction), Unfollow(Pubkey), Follow(Pubkey), + Context(ProfileContext), } struct ProfileScrollResponse { @@ -148,7 +149,7 @@ fn profile_body( ) -> Option { let mut action = None; ui.vertical(|ui| { - banner( + let banner_resp = banner( ui, profile .map(|p| p.record().profile()) @@ -156,6 +157,24 @@ fn profile_body( 120.0, ); + let place_context = { + let mut rect = banner_resp.rect; + let size = 24.0; + rect.set_bottom(rect.top() + size); + rect.set_left(rect.right() - size); + rect.translate(vec2(-16.0, 16.0)) + }; + + let context_resp = ProfileContextWidget::new(place_context).context_button(ui, pubkey); + if let Some(selection) = + ProfileContextWidget::context_menu(ui, note_context.i18n, context_resp) + { + action = Some(ProfileViewAction::Context(ProfileContext { + profile: *pubkey, + selection, + })); + } + let padding = 12.0; notedeck_ui::padding(padding, ui, |ui| { let mut pfp_rect = ui.available_rect_before_wrap();