diff --git a/assets/icons/reply-dark.png b/assets/icons/reply-dark.png new file mode 100644 index 0000000..fabe1b0 Binary files /dev/null and b/assets/icons/reply-dark.png differ diff --git a/assets/icons/reply.png b/assets/icons/reply.png new file mode 100644 index 0000000..d85a55e Binary files /dev/null and b/assets/icons/reply.png differ diff --git a/assets/icons/reply.svg b/assets/icons/reply.svg index db373c3..11076bd 100644 --- a/assets/icons/reply.svg +++ b/assets/icons/reply.svg @@ -1,6 +1 @@ - - - - - - \ No newline at end of file + diff --git a/assets/icons/repost.svg b/assets/icons/repost.svg deleted file mode 100644 index c48957c..0000000 --- a/assets/icons/repost.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/icons/repost_icon_4x.png b/assets/icons/repost_icon_4x.png new file mode 100644 index 0000000..6573f8f Binary files /dev/null and b/assets/icons/repost_icon_4x.png differ diff --git a/assets/icons/repost_light.png b/assets/icons/repost_light.png deleted file mode 100644 index 57efa20..0000000 Binary files a/assets/icons/repost_light.png and /dev/null differ diff --git a/assets/icons/repost_light_4x.png b/assets/icons/repost_light_4x.png new file mode 100644 index 0000000..67646de Binary files /dev/null and b/assets/icons/repost_light_4x.png differ diff --git a/assets/icons/zap.svg b/assets/icons/zap.svg deleted file mode 100644 index f198300..0000000 --- a/assets/icons/zap.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/icons/zap_4x.png b/assets/icons/zap_4x.png new file mode 100644 index 0000000..cc23196 Binary files /dev/null and b/assets/icons/zap_4x.png differ diff --git a/crates/notedeck_ui/src/app_images.rs b/crates/notedeck_ui/src/app_images.rs index 4e80d50..627b8d4 100644 --- a/crates/notedeck_ui/src/app_images.rs +++ b/crates/notedeck_ui/src/app_images.rs @@ -1,5 +1,5 @@ use eframe::icon_data::from_png_bytes; -use egui::{include_image, Color32, IconData, Image}; +use egui::{include_image, IconData, Image}; pub fn app_icon() -> IconData { from_png_bytes(include_bytes!("../../../assets/damus-app-icon.png")).expect("icon") @@ -153,19 +153,19 @@ pub fn notifications_image() -> Image<'static> { )) } pub fn repost_dark_image() -> Image<'static> { - Image::new(include_image!("../../../assets/icons/repost.svg")) + 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.png")) + Image::new(include_image!("../../../assets/icons/repost_light_4x.png")) } pub fn reply_dark_image() -> Image<'static> { - Image::new(include_image!("../../../assets/icons/reply.svg")) + Image::new(include_image!("../../../assets/icons/reply.png")) } pub fn reply_light_image() -> Image<'static> { - Image::new(include_image!("../../../assets/icons/reply.svg")).tint(Color32::BLACK) + Image::new(include_image!("../../../assets/icons/reply-dark.png")) } pub fn profile_image() -> Image<'static> { @@ -203,5 +203,5 @@ pub fn wallet_image() -> Image<'static> { } pub fn zap_image() -> Image<'static> { - Image::new(include_image!("../../../assets/icons/zap.svg")) + Image::new(include_image!("../../../assets/icons/zap_4x.png")) } diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs index aba4281..b4713ba 100644 --- a/crates/notedeck_ui/src/note/mod.rs +++ b/crates/notedeck_ui/src/note/mod.rs @@ -30,10 +30,6 @@ use notedeck::{ NotedeckTextStyle, ZapTarget, Zaps, }; -const ACTION_BAR_ICON_SIZE: f32 = 14.0; -const ACTION_BAR_EXPAND_SIZE: f32 = 5.0; -const ACTION_BAR_ANIM_SPEED: f32 = 0.05; - pub struct NoteView<'a, 'd> { note_context: &'a mut NoteContext<'d>, zapping_acc: Option<&'a KeypairUnowned<'a>>, @@ -71,6 +67,14 @@ impl NoteResponse { } } +/* +impl View for NoteView<'_, '_> { + fn ui(&mut self, ui: &mut egui::Ui) { + self.show(ui); + } +} +*/ + impl egui::Widget for &mut NoteView<'_, '_> { fn ui(self, ui: &mut egui::Ui) -> egui::Response { self.show(ui).response @@ -780,91 +784,73 @@ fn render_note_actionbar( note_pubkey: &[u8; 32], note_key: NoteKey, ) -> egui::InnerResponse> { - ui.add_space(10.0); + ui.horizontal(|ui| 's: { + let reply_resp = reply_button(ui, note_key); + let quote_resp = quote_repost_button(ui, note_key); - let icon_space = ACTION_BAR_ICON_SIZE * 2.0; - let width = ui.available_width(); - let height = 22.0; + let to_noteid = |id: &[u8; 32]| NoteId::new(*id); + if reply_resp.clicked() { + break 's Some(NoteAction::Reply(to_noteid(note_id))); + } else if reply_resp.hovered() { + crate::show_pointer(ui); + } - let (rect, _response) = ui.allocate_exact_size(egui::vec2(width, height), egui::Sense::click()); + if quote_resp.clicked() { + break 's Some(NoteAction::Quote(to_noteid(note_id))); + } else if quote_resp.hovered() { + crate::show_pointer(ui); + } - #[allow(deprecated)] - ui.allocate_ui_at_rect(rect, |ui| { - ui.horizontal(|ui| 's: { - let reply_resp = reply_button(ui, note_key); + let Some(Zapper { zaps, cur_acc }) = zapper else { + break 's None; + }; - ui.add_space(icon_space); + let zap_target = ZapTarget::Note(NoteZapTarget { + note_id, + zap_recipient: note_pubkey, + }); - let quote_resp = quote_repost_button(ui, note_key); + let zap_state = zaps.any_zap_state_for(cur_acc.pubkey.bytes(), zap_target); - let to_noteid = |id: &[u8; 32]| NoteId::new(*id); - if reply_resp.clicked() { - break 's Some(NoteAction::Reply(to_noteid(note_id))); - } else if reply_resp.hovered() { - crate::show_pointer(ui); - } + let target = NoteZapTargetOwned { + note_id: to_noteid(note_id), + zap_recipient: Pubkey::new(*note_pubkey), + }; - if quote_resp.clicked() { - break 's Some(NoteAction::Quote(to_noteid(note_id))); - } else if quote_resp.hovered() { - crate::show_pointer(ui); - } + if zap_state.is_err() { + break 's Some(NoteAction::Zap(ZapAction::ClearError(target))); + } - let Some(Zapper { zaps, cur_acc }) = zapper else { - break 's None; - }; + let zap_resp = { + cur_acc.secret_key.as_ref()?; - let zap_target = ZapTarget::Note(NoteZapTarget { - note_id, - zap_recipient: note_pubkey, - }); - - let zap_state = zaps.any_zap_state_for(cur_acc.pubkey.bytes(), zap_target); - - let target = NoteZapTargetOwned { - note_id: to_noteid(note_id), - zap_recipient: Pubkey::new(*note_pubkey), - }; - - if zap_state.is_err() { - break 's Some(NoteAction::Zap(ZapAction::ClearError(target))); - } - - let zap_resp = { - cur_acc.secret_key.as_ref()?; - - match zap_state { - Ok(any_zap_state) => { - ui.add_space(icon_space); - ui.add(zap_button(any_zap_state, note_id)) - } - Err(err) => { - let (rect, _) = - ui.allocate_at_least(egui::vec2(10.0, 10.0), egui::Sense::click()); - ui.add(x_button(rect)).on_hover_text(err.to_string()) - } + match zap_state { + Ok(any_zap_state) => ui.add(zap_button(any_zap_state, note_id)), + Err(err) => { + let (rect, _) = + ui.allocate_at_least(egui::vec2(10.0, 10.0), egui::Sense::click()); + ui.add(x_button(rect)).on_hover_text(err.to_string()) } - }; - - if zap_resp.hovered() { - crate::show_pointer(ui); } + }; - if zap_resp.secondary_clicked() { - break 's Some(NoteAction::Zap(ZapAction::CustomizeAmount(target))); - } + if zap_resp.hovered() { + crate::show_pointer(ui); + } - if !zap_resp.clicked() { - break 's None; - } + if zap_resp.secondary_clicked() { + break 's Some(NoteAction::Zap(ZapAction::CustomizeAmount(target))); + } - Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount { - target, - specified_msats: None, - }))) - }) + if !zap_resp.clicked() { + break 's None; + } + + Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount { + target, + specified_msats: None, + }))) }) - .inner } fn secondary_label(ui: &mut egui::Ui, s: impl Into) { @@ -892,24 +878,19 @@ fn render_reltime( } fn reply_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response { - let id = ui.id().with(("reply_anim", note_key)); - - let (rect, size, resp) = crate::anim::hover_expand( - ui, - id, - ACTION_BAR_ICON_SIZE, - ACTION_BAR_EXPAND_SIZE, - ACTION_BAR_ANIM_SPEED, - ); - - let rect = rect.translate(egui::vec2(-(ACTION_BAR_EXPAND_SIZE / 2.0), -1.0)); - let img = if ui.style().visuals.dark_mode { app_images::reply_dark_image() } else { app_images::reply_light_image() }; + let (rect, size, resp) = + crate::anim::hover_expand_small(ui, ui.id().with(("reply_anim", note_key))); + + // align rect to note contents + 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.max_width(size)) .on_hover_text("Reply to this note"); @@ -926,17 +907,14 @@ fn repost_icon(dark_mode: bool) -> egui::Image<'static> { } fn quote_repost_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response { + let size = 14.0; + let expand_size = 5.0; + let anim_speed = 0.05; let id = ui.id().with(("repost_anim", note_key)); - let (rect, size, resp) = crate::anim::hover_expand( - ui, - id, - ACTION_BAR_ICON_SIZE, - ACTION_BAR_EXPAND_SIZE, - ACTION_BAR_ANIM_SPEED, - ); + let (rect, size, resp) = crate::anim::hover_expand(ui, id, size, expand_size, anim_speed); - let rect = rect.translate(egui::vec2(-(ACTION_BAR_EXPAND_SIZE / 2.0), -1.0)); + 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)) @@ -947,19 +925,9 @@ fn quote_repost_button(ui: &mut egui::Ui, note_key: NoteKey) -> egui::Response { fn zap_button(state: AnyZapState, noteid: &[u8; 32]) -> impl egui::Widget + use<'_> { move |ui: &mut egui::Ui| -> egui::Response { - let id = ui.id().with(("zap", noteid)); + let (rect, size, resp) = crate::anim::hover_expand_small(ui, ui.id().with("zap")); - let (rect, size, resp) = crate::anim::hover_expand( - ui, - id, - ACTION_BAR_ICON_SIZE, - ACTION_BAR_EXPAND_SIZE, - ACTION_BAR_ANIM_SPEED, - ); - - let mut img = app_images::zap_image() - .max_width(size) - .tint(egui::Color32::WHITE); + let mut img = app_images::zap_image().max_width(size); let id = ui.id().with(("pulse", noteid)); let ctx = ui.ctx().clone();