From d4b70fd85ceafb812c659ff323a920e849a250ef Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Wed, 28 Dec 2022 16:20:26 +1300 Subject: [PATCH] Add copy button to pubkey of post --- src/ui/feed.rs | 4 ++++ src/ui/mod.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/ui/feed.rs b/src/ui/feed.rs index 0da485aa..94b9d9e6 100644 --- a/src/ui/feed.rs +++ b/src/ui/feed.rs @@ -160,6 +160,10 @@ fn render_post( ui.label(RichText::new(GossipUi::pubkey_short(&event.pubkey)).weak()); + if ui.add(CopyButton { }).clicked() { + ui.output().copied_text = GossipUi::pubkey_long(&event.pubkey); + } + ui.with_layout(Layout::right_to_left(Align::TOP), |ui| { ui.label( RichText::new(crate::date_ago::date_ago(event.created_at)) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 8c7a6842..be6618ea 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -198,4 +198,9 @@ impl GossipUi { let hex: PublicKeyHex = (*pubkey).into(); Self::hex_pubkey_short(&hex) } + + pub fn pubkey_long(pubkey: &PublicKey) -> String { + let hex: PublicKeyHex = (*pubkey).into(); + hex.0 + } }