mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-20 18:04:18 +01:00
render profile context button
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -505,7 +505,7 @@ fn process_render_nav_action(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RenderNavAction::ProfileAction(profile_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) => {
|
RenderNavAction::WalletAction(wallet_action) => {
|
||||||
wallet_action.process(ctx.accounts, ctx.global_wallet)
|
wallet_action.process(ctx.accounts, ctx.global_wallet)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use enostr::{FilledKeypair, FullKeypair, ProfileState, Pubkey, RelayPool};
|
use enostr::{FilledKeypair, FullKeypair, ProfileState, Pubkey, RelayPool};
|
||||||
use nostrdb::{Ndb, Note, NoteBuildOptions, NoteBuilder, Transaction};
|
use nostrdb::{Ndb, Note, NoteBuildOptions, NoteBuilder, Transaction};
|
||||||
|
|
||||||
use notedeck::{Accounts, ContactState};
|
use notedeck::{Accounts, ContactState, ProfileContext};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use crate::{nav::RouterAction, route::Route};
|
use crate::{nav::RouterAction, route::Route};
|
||||||
@@ -38,11 +38,13 @@ pub enum ProfileAction {
|
|||||||
SaveChanges(SaveProfileChanges),
|
SaveChanges(SaveProfileChanges),
|
||||||
Follow(Pubkey),
|
Follow(Pubkey),
|
||||||
Unfollow(Pubkey),
|
Unfollow(Pubkey),
|
||||||
|
Context(ProfileContext),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProfileAction {
|
impl ProfileAction {
|
||||||
pub fn process_profile_action(
|
pub fn process_profile_action(
|
||||||
&self,
|
&self,
|
||||||
|
ctx: &egui::Context,
|
||||||
ndb: &Ndb,
|
ndb: &Ndb,
|
||||||
pool: &mut RelayPool,
|
pool: &mut RelayPool,
|
||||||
accounts: &Accounts,
|
accounts: &Accounts,
|
||||||
@@ -77,6 +79,12 @@ impl ProfileAction {
|
|||||||
Self::send_unfollow_user_event(ndb, pool, accounts, target_key);
|
Self::send_unfollow_user_event(ndb, pool, accounts, target_key);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
ProfileAction::Context(profile_context) => {
|
||||||
|
profile_context
|
||||||
|
.selection
|
||||||
|
.process(ctx, &profile_context.profile);
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,5 +129,8 @@ pub fn render_profile_route(
|
|||||||
ui::profile::ProfileViewAction::Unfollow(target_key) => Some(
|
ui::profile::ProfileViewAction::Unfollow(target_key) => Some(
|
||||||
RenderNavAction::ProfileAction(ProfileAction::Unfollow(target_key)),
|
RenderNavAction::ProfileAction(ProfileAction::Unfollow(target_key)),
|
||||||
),
|
),
|
||||||
|
ui::profile::ProfileViewAction::Context(profile_context_selection) => Some(
|
||||||
|
RenderNavAction::ProfileAction(ProfileAction::Context(profile_context_selection)),
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ pub use edit::EditProfileView;
|
|||||||
use egui::{vec2, Color32, CornerRadius, Layout, Rect, RichText, ScrollArea, Sense, Stroke};
|
use egui::{vec2, Color32, CornerRadius, Layout, Rect, RichText, ScrollArea, Sense, Stroke};
|
||||||
use enostr::Pubkey;
|
use enostr::Pubkey;
|
||||||
use nostrdb::{ProfileRecord, Transaction};
|
use nostrdb::{ProfileRecord, Transaction};
|
||||||
use notedeck::{tr, Localization};
|
use notedeck::{tr, Localization, ProfileContext};
|
||||||
use notedeck_ui::profile::follow_button;
|
use notedeck_ui::profile::{context::ProfileContextWidget, follow_button};
|
||||||
use robius_open::Uri;
|
use robius_open::Uri;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
@@ -38,6 +38,7 @@ pub enum ProfileViewAction {
|
|||||||
Note(NoteAction),
|
Note(NoteAction),
|
||||||
Unfollow(Pubkey),
|
Unfollow(Pubkey),
|
||||||
Follow(Pubkey),
|
Follow(Pubkey),
|
||||||
|
Context(ProfileContext),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ProfileScrollResponse {
|
struct ProfileScrollResponse {
|
||||||
@@ -148,7 +149,7 @@ fn profile_body(
|
|||||||
) -> Option<ProfileViewAction> {
|
) -> Option<ProfileViewAction> {
|
||||||
let mut action = None;
|
let mut action = None;
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
banner(
|
let banner_resp = banner(
|
||||||
ui,
|
ui,
|
||||||
profile
|
profile
|
||||||
.map(|p| p.record().profile())
|
.map(|p| p.record().profile())
|
||||||
@@ -156,6 +157,24 @@ fn profile_body(
|
|||||||
120.0,
|
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;
|
let padding = 12.0;
|
||||||
notedeck_ui::padding(padding, ui, |ui| {
|
notedeck_ui::padding(padding, ui, |ui| {
|
||||||
let mut pfp_rect = ui.available_rect_before_wrap();
|
let mut pfp_rect = ui.available_rect_before_wrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user