ui/note: refactor reply line into a function

this is a bit neater

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-07-17 09:36:46 -07:00
parent c0c2120f74
commit 51d2b4414b

View File

@@ -4,6 +4,7 @@ use crate::ui::{
note::{PostAction, PostResponse, PostType}, note::{PostAction, PostResponse, PostType},
}; };
use egui::{Rect, Response, Ui};
use enostr::{FilledKeypair, NoteId}; use enostr::{FilledKeypair, NoteId};
use notedeck::NoteContext; use notedeck::NoteContext;
use notedeck_ui::jobs::JobsCache; use notedeck_ui::jobs::JobsCache;
@@ -102,17 +103,35 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
.action .action
.or(quoted_note.action.map(PostAction::QuotedNoteAction)); .or(quoted_note.action.map(PostAction::QuotedNoteAction));
// reply_line_ui(
// reply line &rect_before_post,
// &post_response.edit_response,
pfp_offset as f32,
&avail_rect,
ui,
);
post_response
})
.inner
}
}
/// The vertical line in the reply view
fn reply_line_ui(
rect_before_post: &Rect,
edit_response: &Response,
pfp_offset: f32,
avail_rect: &Rect,
ui: &mut Ui,
) {
// Position and draw the reply line // Position and draw the reply line
let mut rect = ui.min_rect(); let mut rect = ui.min_rect();
// Position the line right above the poster's profile pic in // Position the line right above the poster's profile pic in
// the post box. Use the PostView's margin values to // the post box. Use the PostView's margin values to
// determine this offset. // determine this offset.
rect.min.x = avail_rect.min.x + pfp_offset as f32; rect.min.x = avail_rect.min.x + pfp_offset;
// honestly don't know what the fuck I'm doing here. just trying // honestly don't know what the fuck I'm doing here. just trying
// to get the line under the profile picture // to get the line under the profile picture
@@ -124,7 +143,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
// For some reason we need to nudge the reply line's height a // For some reason we need to nudge the reply line's height a
// few more pixels? // few more pixels?
let nudge = if post_response.edit_response.has_focus() { let nudge = if edit_response.has_focus() {
// we nudge by one less pixel if focused, otherwise it // we nudge by one less pixel if focused, otherwise it
// overlaps the focused PostView purple border color // overlaps the focused PostView purple border color
2.0 2.0
@@ -141,9 +160,4 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
rect.y_range(), rect.y_range(),
ui.visuals().widgets.noninteractive.bg_stroke, ui.visuals().widgets.noninteractive.bg_stroke,
); );
post_response
})
.inner
}
} }