repost: update style

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-09-17 14:46:21 -07:00
parent 80c9cbe5b2
commit 27aa146300
4 changed files with 23 additions and 18 deletions

View File

@@ -1,7 +1 @@
{ { "limit": 100, "kinds": [ 6 ] }
"limit": 100,
"kinds": [
1, 6
],
"#p": ["32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"]
}

View File

@@ -96,7 +96,7 @@ pub fn mobile_font_size(text_style: &NotedeckTextStyle) -> f32 {
} }
} }
#[derive(EnumIter)] #[derive(Copy, Clone, Eq, PartialEq, Debug, EnumIter)]
pub enum NotedeckTextStyle { pub enum NotedeckTextStyle {
Heading, Heading,
Heading2, Heading2,

View File

@@ -327,19 +327,21 @@ impl<'a> NoteView<'a> {
action: None, action: None,
} }
} else { } else {
let txn = self.note.txn().expect("todo: support non-db notes"); let txn = self.note.txn().expect("txn");
if let Some(note_to_repost) = get_reposted_note(self.ndb, txn, self.note) { if let Some(note_to_repost) = get_reposted_note(self.ndb, txn, self.note) {
let profile = self.ndb.get_profile_by_pubkey(txn, self.note.pubkey()); let profile = self.ndb.get_profile_by_pubkey(txn, self.note.pubkey());
let style = NotedeckTextStyle::Small;
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.vertical(|ui| { ui.vertical(|ui| {
ui.add_space(2.0); ui.add_space(2.0);
ui.add_sized([20.0, 20.0], repost_icon()); ui.add_sized([20.0, 20.0], repost_icon());
}); });
ui.add_space(6.0); ui.add_space(6.0);
let resp = ui.add(one_line_display_name_widget(get_display_name( let resp = ui.add(one_line_display_name_widget(
profile.as_ref().ok(), get_display_name(profile.as_ref().ok()),
))); style,
));
if let Ok(rec) = &profile { if let Ok(rec) = &profile {
resp.on_hover_ui_at_pointer(|ui| { resp.on_hover_ui_at_pointer(|ui| {
ui.set_max_width(300.0); ui.set_max_width(300.0);
@@ -349,7 +351,8 @@ impl<'a> NoteView<'a> {
ui.add_space(4.0); ui.add_space(4.0);
ui.label( ui.label(
RichText::new("Reposted") RichText::new("Reposted")
.text_style(NotedeckTextStyle::Heading3.text_style()), .color(colors::GRAY_SECONDARY)
.text_style(style.text_style()),
); );
}); });
NoteView::new(self.ndb, self.note_cache, self.img_cache, &note_to_repost).show(ui) NoteView::new(self.ndb, self.note_cache, self.img_cache, &note_to_repost).show(ui)

View File

@@ -198,17 +198,25 @@ fn display_name_widget(
} }
} }
pub fn one_line_display_name_widget(display_name: DisplayName<'_>) -> impl egui::Widget + '_ { pub fn one_line_display_name_widget(
display_name: DisplayName<'_>,
style: NotedeckTextStyle,
) -> impl egui::Widget + '_ {
let text_style = style.text_style();
move |ui: &mut egui::Ui| match display_name { move |ui: &mut egui::Ui| match display_name {
DisplayName::One(n) => { DisplayName::One(n) => ui.label(
ui.label(RichText::new(n).text_style(NotedeckTextStyle::Heading3.text_style())) RichText::new(n)
} .text_style(text_style)
.color(colors::GRAY_SECONDARY),
),
DisplayName::Both { DisplayName::Both {
display_name, display_name,
username: _, username: _,
} => ui.label( } => ui.label(
RichText::new(display_name).text_style(NotedeckTextStyle::Heading3.text_style()), RichText::new(display_name)
.text_style(text_style)
.color(colors::GRAY_SECONDARY),
), ),
} }
} }