notedeck

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

commit 61bc9d99192c24e71fd5a7bed03a3b1f7d64703e
parent f795fe6088a3ddb0f6cdac83080c19c5790de319
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 10 Jul 2024 09:52:33 -0700

refactor: rename ui::Note to ui::NoteView

Easier to jump to when using tags.

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

Diffstat:
Msrc/lib.rs | 1+
Msrc/timeline.rs | 4+++-
Msrc/ui/mod.rs | 2+-
Msrc/ui/note/contents.rs | 2+-
Msrc/ui/note/mod.rs | 10+++++-----
Msrc/ui/note/reply.rs | 9+++++----
6 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs @@ -18,6 +18,7 @@ mod key_parsing; mod key_storage; pub mod login_manager; mod macos_key_storage; +mod note; mod notecache; mod post; mod profile; diff --git a/src/timeline.rs b/src/timeline.rs @@ -347,7 +347,9 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) { ui::padding(8.0, ui, |ui| { let textmode = app.textmode; - let resp = ui::Note::new(app, &note).note_previews(!textmode).show(ui); + let resp = ui::NoteView::new(app, &note) + .note_previews(!textmode) + .show(ui); if let Some(action) = resp.action { debug!("bar action: {:?}", action); diff --git a/src/ui/mod.rs b/src/ui/mod.rs @@ -17,7 +17,7 @@ pub use account_switcher::AccountSelectionWidget; pub use fixed_window::{FixedWindow, FixedWindowResponse}; pub use global_popup::DesktopGlobalPopup; pub use mention::Mention; -pub use note::{BarAction, Note, NoteResponse, PostReplyView, PostView}; +pub use note::{BarAction, NoteResponse, NoteView, PostReplyView, PostView}; pub use preview::{Preview, PreviewApp, PreviewConfig}; pub use profile::{profile_preview_controller, ProfilePic, ProfilePreview}; pub use relay::RelayView; diff --git a/src/ui/note/contents.rs b/src/ui/note/contents.rs @@ -89,7 +89,7 @@ fn render_note_preview( ui.visuals().noninteractive().bg_stroke.color, )) .show(ui, |ui| { - ui::Note::new(app, &note) + ui::NoteView::new(app, &note) .actionbar(false) .small_pfp(true) .note_previews(false) diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs @@ -12,7 +12,7 @@ use crate::{colors, notecache::CachedNote, ui, ui::View, Damus}; use egui::{Label, RichText, Sense}; use nostrdb::{NoteKey, Transaction}; -pub struct Note<'a> { +pub struct NoteView<'a> { app: &'a mut Damus, note: &'a nostrdb::Note<'a>, flags: NoteOptions, @@ -23,7 +23,7 @@ pub struct NoteResponse { pub action: Option<BarAction>, } -impl<'a> View for Note<'a> { +impl<'a> View for NoteView<'a> { fn ui(&mut self, ui: &mut egui::Ui) { self.show(ui); } @@ -114,10 +114,10 @@ fn reply_desc( } } -impl<'a> Note<'a> { +impl<'a> NoteView<'a> { pub fn new(app: &'a mut Damus, note: &'a nostrdb::Note<'a>) -> Self { let flags = NoteOptions::actionbar | NoteOptions::note_previews; - Note { app, note, flags } + Self { app, note, flags } } pub fn actionbar(mut self, enable: bool) -> Self { @@ -225,7 +225,7 @@ impl<'a> Note<'a> { ui, egui::Id::new((profile_key, note_key)), pfp_size, - ui::Note::expand_size(), + ui::NoteView::expand_size(), anim_speed, ); diff --git a/src/ui/note/reply.rs b/src/ui/note/reply.rs @@ -39,13 +39,14 @@ impl<'a> PostReplyView<'a> { + ui::PostView::inner_margin() + ui::ProfilePic::small_size() / 2.0; - let note_offset = - pfp_offset - ui::ProfilePic::medium_size() / 2.0 - ui::Note::expand_size() / 2.0; + let note_offset = pfp_offset + - ui::ProfilePic::medium_size() / 2.0 + - ui::NoteView::expand_size() / 2.0; egui::Frame::none() .outer_margin(egui::Margin::same(note_offset)) .show(ui, |ui| { - ui::Note::new(self.app, self.note) + ui::NoteView::new(self.app, self.note) .actionbar(false) .medium_pfp(true) .show(ui); @@ -111,7 +112,7 @@ impl<'a> PostReplyView<'a> { rect.min.y = avail_rect.min.y + (ui::ProfilePic::medium_size() / 2.0 + ui::ProfilePic::medium_size() - + ui::Note::expand_size() * 2.0) + + ui::NoteView::expand_size() * 2.0) + 1.0; // For some reason we need to nudge the reply line's height a