mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 03:33:53 +00:00
ui: render person 'followed', name line more uniform
This commit is contained in:
parent
63d1b3d8ab
commit
9994072485
@ -258,21 +258,7 @@ fn render_post(
|
||||
ui.vertical(|ui| {
|
||||
// First row
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(person) = maybe_person {
|
||||
if let Some(name) = &person.name {
|
||||
ui.label(RichText::new(name).strong());
|
||||
} else {
|
||||
ui.label(RichText::new(GossipUi::pubkey_short(&event.pubkey)).weak());
|
||||
}
|
||||
|
||||
if let Some(dns_id) = &person.dns_id {
|
||||
if person.dns_id_valid > 0 {
|
||||
ui.label(RichText::new(dns_id).monospace().small());
|
||||
} else {
|
||||
ui.label(RichText::new(dns_id).monospace().small().strikethrough());
|
||||
}
|
||||
}
|
||||
}
|
||||
GossipUi::render_person_name_line(ui, maybe_person.as_ref());
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
|
@ -14,7 +14,7 @@ use crate::error::Error;
|
||||
use crate::globals::GLOBALS;
|
||||
use crate::settings::Settings;
|
||||
use eframe::{egui, IconData, Theme};
|
||||
use egui::{ColorImage, Context, ImageData, TextureHandle, TextureOptions};
|
||||
use egui::{ColorImage, Context, ImageData, RichText, TextureHandle, TextureOptions, Ui};
|
||||
use nostr_types::{Id, PublicKey, PublicKeyHex};
|
||||
use std::time::{Duration, Instant};
|
||||
use zeroize::Zeroize;
|
||||
@ -230,4 +230,28 @@ impl GossipUi {
|
||||
let hex: PublicKeyHex = (*pubkey).into();
|
||||
hex.0
|
||||
}
|
||||
|
||||
pub fn render_person_name_line(ui: &mut Ui, maybe_person: Option<&DbPerson>) {
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(person) = maybe_person {
|
||||
if let Some(name) = &person.name {
|
||||
ui.label(RichText::new(name).strong());
|
||||
} else {
|
||||
ui.label(RichText::new(GossipUi::hex_pubkey_short(&person.pubkey)).weak());
|
||||
}
|
||||
|
||||
if person.followed > 0 {
|
||||
ui.label("🚶");
|
||||
}
|
||||
|
||||
if let Some(dns_id) = &person.dns_id {
|
||||
if person.dns_id_valid > 0 {
|
||||
ui.label(RichText::new(dns_id).monospace().small());
|
||||
} else {
|
||||
ui.label(RichText::new(dns_id).monospace().small().strikethrough());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -142,29 +142,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.label(RichText::new(GossipUi::hex_pubkey_short(&person.pubkey)).weak());
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(name) = &person.name {
|
||||
ui.label(RichText::new(name).strong());
|
||||
} else {
|
||||
ui.label(
|
||||
RichText::new(GossipUi::hex_pubkey_short(&person.pubkey))
|
||||
.weak(),
|
||||
);
|
||||
}
|
||||
|
||||
ui.add_space(24.0);
|
||||
|
||||
if let Some(dns_id) = &person.dns_id {
|
||||
if person.dns_id_valid > 0 {
|
||||
ui.label(RichText::new(dns_id).monospace().small());
|
||||
} else {
|
||||
ui.label(
|
||||
RichText::new(dns_id).monospace().small().strikethrough(),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
GossipUi::render_person_name_line(ui, Some(person));
|
||||
});
|
||||
});
|
||||
|
||||
@ -194,32 +172,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.label(RichText::new(GossipUi::hex_pubkey_short(&person.pubkey)).weak());
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(name) = &person.name {
|
||||
ui.label(RichText::new(name).strong());
|
||||
} else {
|
||||
ui.label(
|
||||
RichText::new(GossipUi::hex_pubkey_short(&person.pubkey)).weak(),
|
||||
);
|
||||
}
|
||||
|
||||
ui.add_space(24.0);
|
||||
|
||||
if let Some(dns_id) = &person.dns_id {
|
||||
if person.dns_id_valid > 0 {
|
||||
ui.label(RichText::new(dns_id).monospace().small());
|
||||
} else {
|
||||
ui.label(RichText::new(dns_id).monospace().small().strikethrough());
|
||||
}
|
||||
}
|
||||
|
||||
if person.followed > 0 {
|
||||
ui.label("FOLLOWED");
|
||||
} else {
|
||||
ui.label("not followed");
|
||||
}
|
||||
});
|
||||
GossipUi::render_person_name_line(ui, Some(person));
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user