android/input: add copy/paste context to post input

Fixes: https://github.com/damus-io/notedeck/issues/942
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-07-11 15:36:56 -07:00
parent 6596e89e29
commit 44edffc596
5 changed files with 21 additions and 13 deletions

View File

@@ -23,6 +23,7 @@ pub struct NoteContext<'d> {
pub pool: &'d mut RelayPool,
pub job_pool: &'d mut JobPool,
pub unknown_ids: &'d mut UnknownIds,
pub clipboard: &'d mut egui_winit::clipboard::Clipboard,
pub current_account_has_wallet: bool,
}

View File

@@ -432,6 +432,7 @@ fn render_nav_body(
pool: ctx.pool,
job_pool: ctx.job_pool,
unknown_ids: ctx.unknown_ids,
clipboard: ctx.clipboard,
current_account_has_wallet: get_current_wallet(ctx.accounts, ctx.global_wallet).is_some(),
};
match top {
@@ -604,7 +605,7 @@ fn render_nav_body(
&(&ctx.accounts.get_selected_account().key).into(),
&mut app.jobs,
)
.show(ui, ctx.clipboard)
.show(ui)
.map(RenderNavAction::NoteAction)
}
Route::NewDeck => {

View File

@@ -14,12 +14,13 @@ use egui::{
};
use enostr::{FilledKeypair, FullKeypair, KeypairUnowned, NoteId, Pubkey, RelayPool};
use nostrdb::{Ndb, Transaction};
use notedeck_ui::app_images;
use notedeck_ui::blur::PixelDimensions;
use notedeck_ui::images::{get_render_state, RenderState};
use notedeck_ui::jobs::JobsCache;
use notedeck_ui::{
app_images,
blur::PixelDimensions,
context_menu::{input_context, PasteBehavior},
gif::{handle_repaint, retrieve_latest_texture},
images::{get_render_state, RenderState},
jobs::JobsCache,
note::render_note_preview,
NoteOptions, ProfilePic,
};
@@ -186,6 +187,13 @@ impl<'a, 'd> PostView<'a, 'd> {
let out = textedit.show(ui);
input_context(
&out.response,
self.note_context.clipboard,
&mut self.draft.buffer.text_buffer,
PasteBehavior::Append,
);
if updated_layout {
self.draft.buffer.selected_mention = false;
}
@@ -792,6 +800,7 @@ mod preview {
job_pool: app.job_pool,
unknown_ids: app.unknown_ids,
current_account_has_wallet: false,
clipboard: app.clipboard,
};
PostView::new(

View File

@@ -52,22 +52,18 @@ impl<'a, 'd> SearchView<'a, 'd> {
}
}
pub fn show(&mut self, ui: &mut egui::Ui, clipboard: &mut Clipboard) -> Option<NoteAction> {
padding(8.0, ui, |ui| self.show_impl(ui, clipboard)).inner
pub fn show(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
padding(8.0, ui, |ui| self.show_impl(ui)).inner
}
pub fn show_impl(
&mut self,
ui: &mut egui::Ui,
clipboard: &mut Clipboard,
) -> Option<NoteAction> {
pub fn show_impl(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
ui.spacing_mut().item_spacing = egui::vec2(0.0, 12.0);
let search_resp = search_box(
&mut self.query.string,
self.query.focus_state.clone(),
ui,
clipboard,
self.note_context.clipboard,
);
search_resp.process(self.query);

View File

@@ -217,6 +217,7 @@ impl<'a> DaveUi<'a> {
pool: ctx.pool,
job_pool: ctx.job_pool,
unknown_ids: ctx.unknown_ids,
clipboard: ctx.clipboard,
current_account_has_wallet: false,
};