notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit bff0f3f628ce31ee141a7f71ea546b76dba38fed
parent afb375356bcd89c814ee6c6536dbcacf7ecf8f11
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 11 Jun 2024 16:10:18 -0700

fix inline note preview colors

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/colors.rs | 4++--
Msrc/timeline.rs | 7++++---
Msrc/ui/note/contents.rs | 7++++---
Msrc/ui/note/mod.rs | 158+++++++++++++++++++++++++++++++++++++++----------------------------------------
4 files changed, 88 insertions(+), 88 deletions(-)

diff --git a/src/colors.rs b/src/colors.rs @@ -66,8 +66,8 @@ pub fn desktop_dark_color_theme() -> ColorTheme { // NONINTERACTIVE WIDGET noninteractive_bg_fill: DARK_ISH_BG, - noninteractive_weak_bg_fill: SEMI_DARKER_BG, - noninteractive_bg_stroke_color: DARK_BG, + noninteractive_weak_bg_fill: DARK_BG, + noninteractive_bg_stroke_color: SEMI_DARKER_BG, noninteractive_fg_stroke_color: GRAY_SECONDARY, // INACTIVE WIDGET diff --git a/src/timeline.rs b/src/timeline.rs @@ -296,9 +296,10 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) { return 0; }; - let textmode = app.textmode; - let note_ui = ui::Note::new(app, &note).note_previews(!textmode); - ui.add(note_ui); + ui::padding(8.0, ui, |ui| { + let textmode = app.textmode; + ui.add(ui::Note::new(app, &note).note_previews(!textmode)); + }); ui::hline(ui); //ui.add(egui::Separator::default().spacing(0.0)); diff --git a/src/ui/note/contents.rs b/src/ui/note/contents.rs @@ -80,12 +80,13 @@ fn render_note_preview( }; egui::Frame::none() - //.fill(egui::Color32::BLACK.gamma_multiply(0.2)) - // + .fill(ui.visuals().noninteractive().bg_fill) + .inner_margin(egui::Margin::same(8.0)) + .outer_margin(egui::Margin::symmetric(0.0, 8.0)) .rounding(egui::Rounding::same(10.0)) .stroke(egui::Stroke::new( 1.0, - egui::Color32::from_rgb(0x2C, 0x2C, 0x2C), + ui.visuals().noninteractive().bg_stroke.color, )) .show(ui, |ui| { ui.add( diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs @@ -192,92 +192,90 @@ impl<'a> Note<'a> { let note_key = self.note.key().expect("todo: support non-db notes"); let txn = self.note.txn().expect("todo: support non-db notes"); - crate::ui::padding(12.0, ui, |ui| { - ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| { - ui.spacing_mut().item_spacing.x = 16.0; - - let profile = self.app.ndb.get_profile_by_pubkey(txn, self.note.pubkey()); - - match profile - .as_ref() - .ok() - .and_then(|p| p.record().profile()?.picture()) - { - // these have different lifetimes and types, - // so the calls must be separate - Some(pic) => { - let expand_size = 5.0; - let anim_speed = 0.05; - let profile_key = profile.as_ref().unwrap().record().note_key(); - let note_key = note_key.as_u64(); - - if self.app.is_mobile() { - ui.add(ui::ProfilePic::new(&mut self.app.img_cache, pic)); - } else { - let (rect, size) = ui::anim::hover_expand( - ui, - egui::Id::new(ProfileAnimId { - profile_key, - note_key, - }), - ui::ProfilePic::default_size(), - expand_size, - anim_speed, - ); - - ui.put( - rect, - ui::ProfilePic::new(&mut self.app.img_cache, pic).size(size), - ) - .on_hover_ui_at_pointer(|ui| { - ui.set_max_width(300.0); - ui.add(ui::ProfilePreview::new( - profile.as_ref().unwrap(), - &mut self.app.img_cache, - )); - }); - } - } - None => { - ui.add(ui::ProfilePic::new( - &mut self.app.img_cache, - ui::ProfilePic::no_pfp_url(), - )); - } - } + ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| { + ui.spacing_mut().item_spacing.x = 16.0; - ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 2.0; - ui.add( - ui::Username::new(profile.as_ref().ok(), self.note.pubkey()) - .abbreviated(20), + let profile = self.app.ndb.get_profile_by_pubkey(txn, self.note.pubkey()); + + match profile + .as_ref() + .ok() + .and_then(|p| p.record().profile()?.picture()) + { + // these have different lifetimes and types, + // so the calls must be separate + Some(pic) => { + let expand_size = 5.0; + let anim_speed = 0.05; + let profile_key = profile.as_ref().unwrap().record().note_key(); + let note_key = note_key.as_u64(); + + if self.app.is_mobile() { + ui.add(ui::ProfilePic::new(&mut self.app.img_cache, pic)); + } else { + let (rect, size) = ui::anim::hover_expand( + ui, + egui::Id::new(ProfileAnimId { + profile_key, + note_key, + }), + ui::ProfilePic::default_size(), + expand_size, + anim_speed, ); - let cached_note = self - .app - .note_cache_mut() - .cached_note_or_insert_mut(note_key, self.note); - render_reltime(ui, cached_note, true); - }); - - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 2.0; - reply_desc(ui, txn, self.app, note_key, self.note); - }); - - ui.add(NoteContents::new( - self.app, - txn, - self.note, - note_key, - self.options(), + ui.put( + rect, + ui::ProfilePic::new(&mut self.app.img_cache, pic).size(size), + ) + .on_hover_ui_at_pointer(|ui| { + ui.set_max_width(300.0); + ui.add(ui::ProfilePreview::new( + profile.as_ref().unwrap(), + &mut self.app.img_cache, + )); + }); + } + } + None => { + ui.add(ui::ProfilePic::new( + &mut self.app.img_cache, + ui::ProfilePic::no_pfp_url(), )); + } + } - if self.options().has_actionbar() { - render_note_actionbar(ui); - } + ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 2.0; + ui.add( + ui::Username::new(profile.as_ref().ok(), self.note.pubkey()) + .abbreviated(20), + ); + + let cached_note = self + .app + .note_cache_mut() + .cached_note_or_insert_mut(note_key, self.note); + render_reltime(ui, cached_note, true); + }); + + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 2.0; + reply_desc(ui, txn, self.app, note_key, self.note); }); + + ui.add(NoteContents::new( + self.app, + txn, + self.note, + note_key, + self.options(), + )); + + if self.options().has_actionbar() { + render_note_actionbar(ui); + } }); }) .response