Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-04 committed Jan 31, 2025
1 parent 803f427 commit cd72cc3
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 25 deletions.
6 changes: 5 additions & 1 deletion crates/notedeck_columns/src/ui/column/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
})
}

Expand Down
21 changes: 13 additions & 8 deletions crates/notedeck_columns/src/ui/note/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,19 @@ impl<'a> NoteView<'a> {
anim_speed,
);

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(
profile.as_ref().unwrap(),
self.img_cache,
));
});
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(
profile.as_ref().unwrap(),
self.img_cache,
));
});

if resp.hovered() || resp.clicked() {
ui::show_pointer(ui);
Expand Down
10 changes: 7 additions & 3 deletions crates/notedeck_columns/src/ui/note/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
.size(pfp_size)
.border(2.0)));
.and_then(|p| {
Some(
ui::ProfilePic::from_profile(self.img_cache, p)?
.size(pfp_size)
.border(2.0),
)
});

if let Some(pfp) = poster_pfp {
ui.add(pfp);
Expand Down
4 changes: 3 additions & 1 deletion crates/notedeck_columns/src/ui/profile/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
30 changes: 22 additions & 8 deletions crates/notedeck_columns/src/ui/profile/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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!();

Expand Down Expand Up @@ -198,11 +207,16 @@ mod preview {
anim_speed,
);

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));
});
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));
});
}
});
});
Expand Down
8 changes: 5 additions & 3 deletions crates/notedeck_columns/src/ui/profile/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
.size(48.0)
.border(1.5));
ui.add(
ProfilePic::new(self.cache, get_profile_url(self.profile))
.size(48.0)
.border(2.0),
);
ui.vertical(|ui| {
ui.add(display_name_widget(get_display_name(self.profile), true));
if !self.is_nsec {
Expand Down
4 changes: 3 additions & 1 deletion crates/notedeck_columns/src/ui/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit cd72cc3

Please sign in to comment.