fix formatting

This commit is contained in:
jglad
2025-01-31 08:41:25 +01:00
parent 803f427f77
commit cd72cc36e8
7 changed files with 58 additions and 25 deletions

View File

@@ -398,7 +398,11 @@ impl<'a> NavTitle<'a> {
.as_ref()
.ok()
.and_then(move |p| {
Some(ui::ProfilePic::from_profile(self.img_cache, p)?.size(pfp_size).border(2.0))
Some(
ui::ProfilePic::from_profile(self.img_cache, p)?
.size(pfp_size)
.border(2.0),
)
})
}

View File

@@ -228,7 +228,12 @@ impl<'a> NoteView<'a> {
anim_speed,
);
ui.put(rect, ui::ProfilePic::new(self.img_cache, pic).size(size).border(2.0))
ui.put(
rect,
ui::ProfilePic::new(self.img_cache, pic)
.size(size)
.border(2.0),
)
.on_hover_ui_at_pointer(|ui| {
ui.set_max_width(300.0);
ui.add(ui::ProfilePreview::new(

View File

@@ -113,9 +113,13 @@ impl<'a> PostView<'a> {
.get_profile_by_pubkey(txn, self.poster.pubkey.bytes())
.as_ref()
.ok()
.and_then(|p| Some(ui::ProfilePic::from_profile(self.img_cache, p)?
.and_then(|p| {
Some(
ui::ProfilePic::from_profile(self.img_cache, p)?
.size(pfp_size)
.border(2.0)));
.border(2.0),
)
});
if let Some(pfp) = poster_pfp {
ui.add(pfp);

View File

@@ -62,7 +62,9 @@ impl<'a> EditProfileView<'a> {
});
ui.put(
pfp_rect,
ProfilePic::new(self.img_cache, pfp_url).size(size).border(2.0),
ProfilePic::new(self.img_cache, pfp_url)
.size(size)
.border(2.0),
);
in_frame(ui, |ui| {

View File

@@ -22,7 +22,12 @@ impl egui::Widget for ProfilePic<'_, '_> {
impl<'cache, 'url> ProfilePic<'cache, 'url> {
pub fn new(cache: &'cache mut ImageCache, url: &'url str) -> Self {
let size = Self::default_size();
ProfilePic { cache, url, size, border: None }
ProfilePic {
cache,
url,
size,
border: None,
}
}
pub fn from_profile(
@@ -117,8 +122,12 @@ fn render_pfp(
}
}
fn pfp_image(ui: &mut egui::Ui, img: &TextureHandle, size: f32, border: Option<f32>)
-> egui::Response {
fn pfp_image(
ui: &mut egui::Ui,
img: &TextureHandle,
size: f32,
border: Option<f32>,
) -> egui::Response {
#[cfg(feature = "profiling")]
puffin::profile_function!();
@@ -198,7 +207,12 @@ mod preview {
anim_speed,
);
ui.put(rect, ui::ProfilePic::new(app.img_cache, url).size(size).border(2.0))
ui.put(
rect,
ui::ProfilePic::new(app.img_cache, url)
.size(size)
.border(2.0),
)
.on_hover_ui_at_pointer(|ui| {
ui.set_max_width(300.0);
ui.add(ui::ProfilePreview::new(&profile, app.img_cache));

View File

@@ -91,9 +91,11 @@ impl egui::Widget for SimpleProfilePreview<'_, '_> {
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
Frame::none()
.show(ui, |ui| {
ui.add(ProfilePic::new(self.cache, get_profile_url(self.profile))
ui.add(
ProfilePic::new(self.cache, get_profile_url(self.profile))
.size(48.0)
.border(1.5));
.border(2.0),
);
ui.vertical(|ui| {
ui.add(display_name_widget(get_display_name(self.profile), true));
if !self.is_nsec {

View File

@@ -266,7 +266,9 @@ impl<'a> DesktopSidePanel<'a> {
let txn = nostrdb::Transaction::new(self.ndb).expect("should be able to create txn");
let profile_url = get_account_url(&txn, self.ndb, self.selected_account);
let widget = ProfilePic::new(self.img_cache, profile_url).size(cur_pfp_size).border(2.0);
let widget = ProfilePic::new(self.img_cache, profile_url)
.size(cur_pfp_size)
.border(2.0);
ui.put(helper.get_animation_rect(), widget);