Show key copy button in person list

This commit is contained in:
Mike Dilger 2023-01-01 15:44:10 +13:00
parent 0297cdf4ae
commit 6acff785c6
2 changed files with 10 additions and 6 deletions

View File

@ -5,7 +5,7 @@ use crate::ui::widgets::{CopyButton, ReplyButton};
use eframe::egui; use eframe::egui;
use egui::{ use egui::{
Align, Color32, Context, Frame, Image, Label, Layout, RichText, ScrollArea, Sense, TextEdit, Align, Color32, Context, Frame, Image, Label, Layout, RichText, ScrollArea, Sense, TextEdit,
TextStyle, Ui, Vec2, Ui, Vec2,
}; };
use nostr_types::{EventKind, Id, PublicKeyHex}; use nostr_types::{EventKind, Id, PublicKeyHex};
@ -273,10 +273,6 @@ fn render_post(
ui.add_space(8.0); ui.add_space(8.0);
ui.label(RichText::new("🔑").text_style(TextStyle::Small).weak());
if ui.add(CopyButton {}).clicked() {
ui.output().copied_text = GossipUi::pubkey_long(&event.pubkey);
}
if event.pow() > 0 { if event.pow() > 0 {
ui.label(format!("POW={}", event.pow())); ui.label(format!("POW={}", event.pow()));
} }

View File

@ -13,8 +13,11 @@ use crate::db::DbPerson;
use crate::error::Error; use crate::error::Error;
use crate::globals::GLOBALS; use crate::globals::GLOBALS;
use crate::settings::Settings; use crate::settings::Settings;
use crate::ui::widgets::CopyButton;
use eframe::{egui, IconData, Theme}; use eframe::{egui, IconData, Theme};
use egui::{ColorImage, Context, ImageData, RichText, TextureHandle, TextureOptions, Ui}; use egui::{
ColorImage, Context, ImageData, RichText, TextStyle, TextureHandle, TextureOptions, Ui,
};
use nostr_types::{Id, PublicKey, PublicKeyHex}; use nostr_types::{Id, PublicKey, PublicKeyHex};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@ -226,6 +229,7 @@ impl GossipUi {
) )
} }
#[allow(dead_code)]
pub fn pubkey_long(pubkey: &PublicKey) -> String { pub fn pubkey_long(pubkey: &PublicKey) -> String {
let hex: PublicKeyHex = (*pubkey).into(); let hex: PublicKeyHex = (*pubkey).into();
hex.0 hex.0
@ -251,6 +255,10 @@ impl GossipUi {
ui.label(RichText::new(dns_id).monospace().small().strikethrough()); ui.label(RichText::new(dns_id).monospace().small().strikethrough());
} }
} }
ui.label(RichText::new("🔑").text_style(TextStyle::Small).weak());
if ui.add(CopyButton {}).clicked() {
ui.output().copied_text = person.pubkey.0.to_owned();
}
} }
}); });
} }