Merge remote-tracking branches 'github/pr/877' and 'github/pr/885'
Some checks failed
CI / Rustfmt + Clippy (push) Has been cancelled
CI / Check (android) (push) Has been cancelled
CI / Test (Linux) (push) Has been cancelled
CI / Test (macOS) (push) Has been cancelled
CI / Test (Windows) (push) Has been cancelled
CI / rpm/deb (aarch64) (push) Has been cancelled
CI / rpm/deb (x86_64) (push) Has been cancelled
CI / macOS dmg (aarch64) (push) Has been cancelled
CI / macOS dmg (x86_64) (push) Has been cancelled
CI / Windows Installer (aarch64) (push) Has been cancelled
CI / Windows Installer (x86_64) (push) Has been cancelled
CI / Upload Artifacts to Server (push) Has been cancelled

Fernando López Guevara (2):
      fix(content): handle case where notes are not loaded
      feat(app_images): add module to manage static app image assets
This commit is contained in:
William Casarin
2025-06-25 10:29:49 -07:00
25 changed files with 382 additions and 183 deletions

View File

@@ -0,0 +1,207 @@
use eframe::icon_data::from_png_bytes;
use egui::{include_image, IconData, Image};
pub fn app_icon() -> IconData {
from_png_bytes(include_bytes!("../../../assets/damus-app-icon.png")).expect("icon")
}
pub fn add_account_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/add_account_icon_4x.png"
))
}
pub fn add_column_dark_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/add_column_dark_4x.png"
))
}
pub fn add_column_light_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/add_column_light_4x.png"
))
}
pub fn add_relay_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/add_relay_icon_4x.png"
))
}
pub fn algo_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/algo.png"))
}
pub fn columns_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/columns_80.png"))
}
pub fn connected_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/connected_icon_4x.png"
))
}
pub fn connecting_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/connecting_icon_4x.png"
))
}
pub fn damus_image() -> Image<'static> {
Image::new(include_image!("../../../assets/damus_rounded_80.png"))
}
pub fn delete_dark_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/column_delete_icon_4x.png"
))
}
pub fn delete_light_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/column_delete_icon_light_4x.png"
))
}
pub fn disconnected_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/disconnected_icon_4x.png"
))
}
pub fn edit_dark_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/edit_icon_4x_dark.png"
))
}
pub fn eye_dark_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/eye-dark.png"))
}
pub fn eye_light_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/eye-light.png"))
}
pub fn eye_slash_dark_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/eye-slash-dark.png"))
}
pub fn eye_slash_light_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/eye-slash-light.png"))
}
pub fn filled_zap_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/filled_zap_icon.svg"))
}
pub fn hashtag_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/hashtag_icon_4x.png"))
}
pub fn help_dark_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/help_icon_dark_4x.png"
))
}
pub fn help_light_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/help_icon_inverted_4x.png"
))
}
pub fn home_button_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/home-toolbar.png"))
}
pub fn home_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/home_icon_dark_4x.png"
))
}
pub fn key_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/key_4x.png"))
}
pub fn link_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/links_4x.png"))
}
pub fn new_message_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/newmessage_64.png"))
}
pub fn new_deck_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/new_deck_icon_4x_dark.png"
))
}
pub fn notifications_button_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/notifications_dark_4x.png"
))
}
pub fn notifications_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/notifications_icon_dark_4x.png"
))
}
pub fn repost_dark_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/repost_icon_4x.png"))
}
pub fn repost_light_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/repost_light_4x.png"))
}
pub fn reply_dark_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/reply.png"))
}
pub fn reply_light_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/reply-dark.png"))
}
pub fn profile_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/profile_icon_4x.png"))
}
pub fn settings_dark_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/settings_dark_4x.png"))
}
pub fn settings_light_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/settings_light_4x.png"
))
}
pub fn universe_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/universe_icon_dark_4x.png"
))
}
pub fn verified_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/verified_4x.png"))
}
pub fn media_upload_dark_image() -> Image<'static> {
Image::new(include_image!(
"../../../assets/icons/media_upload_dark_4x.png"
))
}
pub fn wallet_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/wallet-icon.svg"))
}
pub fn zap_image() -> Image<'static> {
Image::new(include_image!("../../../assets/icons/zap_4x.png"))
}

View File

@@ -1,4 +1,5 @@
pub mod anim;
pub mod app_images;
pub mod blur;
pub mod colors;
pub mod constants;

View File

@@ -89,6 +89,10 @@ pub fn render_note_preview(
));
}
} else {
note_context
.unknown_ids
.add_note_id_if_missing(note_context.ndb, txn, id);
return NoteResponse::new(ui.colored_label(Color32::RED, "TODO: COULD NOT LOAD"));
/*
return ui

View File

@@ -10,6 +10,7 @@ use notedeck::{
};
use crate::{
app_images,
blur::{compute_blurhash, Blur, ObfuscationType, PointDimensions},
gif::{handle_repaint, retrieve_latest_texture},
images::{fetch_no_pfp_promise, get_render_state, ImageType},
@@ -537,8 +538,6 @@ fn render_blur_text(ui: &mut egui::Ui, url: &str, render_rect: egui::Rect) -> eg
let text_style = NotedeckTextStyle::Button;
let icon_data = egui::include_image!("../../../../assets/icons/eye-slash-dark.png");
let icon_size = helper.scale_1d_pos(30.0);
let animation_fontid = FontId::new(
helper.scale_1d_pos(get_font_size(ui.ctx(), &text_style)),
@@ -568,9 +567,13 @@ fn render_blur_text(ui: &mut egui::Ui, url: &str, render_rect: egui::Rect) -> eg
egui::Rect::from_center_size(center, egui::vec2(icon_size, icon_size))
};
egui::Image::new(icon_data)
.max_width(icon_size)
.paint_at(ui, icon_rect);
(if ui.visuals().dark_mode {
app_images::eye_slash_dark_image()
} else {
app_images::eye_slash_light_image()
})
.max_width(icon_size)
.paint_at(ui, icon_rect);
let info_galley_pos = {
let mut pos = icon_rect.center();

View File

@@ -4,6 +4,7 @@ pub mod media;
pub mod options;
pub mod reply_description;
use crate::app_images;
use crate::jobs::JobsCache;
use crate::{
profile::name::one_line_display_name_widget, widgets::x_button, ProfilePic, ProfilePreview,
@@ -877,10 +878,10 @@ fn render_reltime(
}
fn reply_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response {
let img_data = if ui.style().visuals.dark_mode {
egui::include_image!("../../../../assets/icons/reply.png")
let img = if ui.style().visuals.dark_mode {
app_images::reply_dark_image()
} else {
egui::include_image!("../../../../assets/icons/reply-dark.png")
app_images::reply_light_image()
};
let (rect, size, resp) =
@@ -890,18 +891,19 @@ fn reply_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response {
let expand_size = 5.0; // from hover_expand_small
let rect = rect.translate(egui::vec2(-(expand_size / 2.0), 0.0));
let put_resp = ui.put(rect, egui::Image::new(img_data).max_width(size));
let put_resp = ui
.put(rect, img.max_width(size))
.on_hover_text("Reply to this note");
resp.union(put_resp)
}
fn repost_icon(dark_mode: bool) -> egui::Image<'static> {
let img_data = if dark_mode {
egui::include_image!("../../../../assets/icons/repost_icon_4x.png")
if dark_mode {
app_images::repost_dark_image()
} else {
egui::include_image!("../../../../assets/icons/repost_light_4x.png")
};
egui::Image::new(img_data)
app_images::repost_light_image()
}
}
fn quote_repost_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response {
@@ -914,18 +916,18 @@ fn quote_repost_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response {
let rect = rect.translate(egui::vec2(-(expand_size / 2.0), -1.0));
let put_resp = ui.put(rect, repost_icon(ui.visuals().dark_mode).max_width(size));
let put_resp = ui
.put(rect, repost_icon(ui.visuals().dark_mode).max_width(size))
.on_hover_text("Repost this note");
resp.union(put_resp)
}
fn zap_button(state: AnyZapState, noteid: &[u8; 32]) -> impl egui::Widget + use<'_> {
move |ui: &mut egui::Ui| -> egui::Response {
let img_data = egui::include_image!("../../../../assets/icons/zap_4x.png");
let (rect, size, resp) = crate::anim::hover_expand_small(ui, ui.id().with("zap"));
let mut img = egui::Image::new(img_data).max_width(size);
let mut img = app_images::zap_image().max_width(size);
let id = ui.id().with(("pulse", noteid));
let ctx = ui.ctx().clone();
@@ -954,7 +956,7 @@ fn zap_button(state: AnyZapState, noteid: &[u8; 32]) -> impl egui::Widget + use<
let expand_size = 5.0; // from hover_expand_small
let rect = rect.translate(egui::vec2(-(expand_size / 2.0), 0.0));
let put_resp = ui.put(rect, img);
let put_resp = ui.put(rect, img).on_hover_text("Zap this note");
resp.union(put_resp)
}

View File

@@ -10,6 +10,8 @@ pub use preview::ProfilePreview;
use egui::{load::TexturePoll, Label, RichText};
use notedeck::{NostrName, NotedeckTextStyle};
use crate::app_images;
pub fn display_name_widget<'a>(
name: &'a NostrName<'a>,
add_placeholder_space: bool,
@@ -38,9 +40,8 @@ pub fn display_name_widget<'a>(
});
let nip05_resp = name.nip05.map(|nip05| {
ui.image(egui::include_image!(
"../../../../assets/icons/verified_4x.png"
));
ui.add(app_images::verified_image());
ui.add(Label::new(
RichText::new(nip05).size(16.0).color(crate::colors::TEAL),
))