From a99dad7e9ad1320cf8112dc079cc9ee64703e0e8 Mon Sep 17 00:00:00 2001 From: kernelkind Date: Wed, 1 Jan 2025 17:16:32 -0500 Subject: [PATCH] profile body Signed-off-by: kernelkind --- crates/notedeck_columns/src/ui/profile/mod.rs | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs index 00e69b0b..a7945996 100644 --- a/crates/notedeck_columns/src/ui/profile/mod.rs +++ b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -5,7 +5,7 @@ use crate::ui::note::NoteOptions; use crate::{colors, images}; use crate::{notes_holder::NotesHolder, DisplayName}; use egui::load::TexturePoll; -use egui::{Label, RichText, ScrollArea, Sense, Widget}; +use egui::{Label, RichText, ScrollArea, Sense}; use enostr::Pubkey; use nostrdb::{Ndb, ProfileRecord, Transaction}; pub use picture::ProfilePic; @@ -56,7 +56,7 @@ impl<'a> ProfileView<'a> { .show(ui, |ui| { let txn = Transaction::new(self.ndb).expect("txn"); if let Ok(profile) = self.ndb.get_profile_by_pubkey(&txn, self.pubkey.bytes()) { - ProfilePreview::new(&profile, self.img_cache).ui(ui); + self.profile_body(ui, profile); } let profile = self .profiles @@ -92,6 +92,43 @@ impl<'a> ProfileView<'a> { }) .inner } + + fn profile_body(&mut self, ui: &mut egui::Ui, profile: ProfileRecord<'_>) { + ui.vertical(|ui| { + ui.add_sized([ui.available_size().x, 120.0], |ui: &mut egui::Ui| { + banner(ui, &profile) + }); + + let padding = 12.0; + crate::ui::padding(padding, ui, |ui| { + let mut pfp_rect = ui.available_rect_before_wrap(); + let size = 80.0; + pfp_rect.set_width(size); + pfp_rect.set_height(size); + let pfp_rect = pfp_rect.translate(egui::vec2(0.0, -(padding + 2.0 + (size / 2.0)))); + + ui.put( + pfp_rect, + ProfilePic::new(self.img_cache, get_profile_url(Some(&profile))).size(size), + ); + ui.add(display_name_widget(get_display_name(Some(&profile)), false)); + ui.add(about_section_widget(&profile)); + + if let Some(website_url) = profile.record().profile().and_then(|p| p.website()) { + if ui + .label(RichText::new(website_url).color(colors::PINK)) + .on_hover_cursor(egui::CursorIcon::PointingHand) + .interact(Sense::click()) + .clicked() + { + if let Err(e) = open::that(website_url) { + error!("Failed to open URL {} because: {}", website_url, e); + }; + } + } + }); + }); + } } fn display_name_widget(