ui/mention: fix weird mention text size

Fixes: https://github.com/damus-io/notedeck/issues/975
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-07-16 17:35:54 -07:00
parent a603685fac
commit 99646f8ff5

View File

@@ -10,7 +10,7 @@ pub struct Mention<'a> {
txn: &'a Transaction, txn: &'a Transaction,
pk: &'a [u8; 32], pk: &'a [u8; 32],
selectable: bool, selectable: bool,
size: f32, size: Option<f32>,
} }
impl<'a> Mention<'a> { impl<'a> Mention<'a> {
@@ -20,7 +20,7 @@ impl<'a> Mention<'a> {
txn: &'a Transaction, txn: &'a Transaction,
pk: &'a [u8; 32], pk: &'a [u8; 32],
) -> Self { ) -> Self {
let size = 16.0; let size = None;
let selectable = true; let selectable = true;
Mention { Mention {
ndb, ndb,
@@ -38,7 +38,7 @@ impl<'a> Mention<'a> {
} }
pub fn size(mut self, size: f32) -> Self { pub fn size(mut self, size: f32) -> Self {
self.size = size; self.size = Some(size);
self self
} }
@@ -63,7 +63,7 @@ fn mention_ui(
txn: &Transaction, txn: &Transaction,
pk: &[u8; 32], pk: &[u8; 32],
ui: &mut egui::Ui, ui: &mut egui::Ui,
size: f32, size: Option<f32>,
selectable: bool, selectable: bool,
) -> Option<NoteAction> { ) -> Option<NoteAction> {
let link_color = ui.visuals().hyperlink_color; let link_color = ui.visuals().hyperlink_color;
@@ -75,9 +75,14 @@ fn mention_ui(
get_display_name(profile.as_ref()).username_or_displayname() get_display_name(profile.as_ref()).username_or_displayname()
); );
let mut text = egui::RichText::new(name).color(link_color);
if let Some(size) = size {
text = text.size(size);
}
let resp = ui let resp = ui
.add( .add(
egui::Label::new(egui::RichText::new(name).color(link_color).size(size)) egui::Label::new(text)
.sense(Sense::click()) .sense(Sense::click())
.selectable(selectable), .selectable(selectable),
) )