From 13021afa58884ee5f6580896a3ff4f7100bfed28 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 9 Jul 2025 11:16:22 -0700 Subject: [PATCH] Revert "feat(note-actionbar): refine icons" icons are too blurry, lets fix that This reverts commit e1bd1d3e8b3a368bd9d5cab5d696e8e80582228f. --- assets/icons/reply-dark.png | Bin 0 -> 912 bytes assets/icons/reply.png | Bin 0 -> 1205 bytes assets/icons/reply.svg | 7 +- assets/icons/repost.svg | 1 - assets/icons/repost_icon_4x.png | Bin 0 -> 808 bytes assets/icons/repost_light.png | Bin 959 -> 0 bytes assets/icons/repost_light_4x.png | Bin 0 -> 1145 bytes assets/icons/zap.svg | 1 - assets/icons/zap_4x.png | Bin 0 -> 866 bytes crates/notedeck_ui/src/app_images.rs | 12 +- crates/notedeck_ui/src/note/mod.rs | 180 +++++++++++---------------- 11 files changed, 81 insertions(+), 120 deletions(-) create mode 100644 assets/icons/reply-dark.png create mode 100644 assets/icons/reply.png delete mode 100644 assets/icons/repost.svg create mode 100644 assets/icons/repost_icon_4x.png delete mode 100644 assets/icons/repost_light.png create mode 100644 assets/icons/repost_light_4x.png delete mode 100644 assets/icons/zap.svg create mode 100644 assets/icons/zap_4x.png diff --git a/assets/icons/reply-dark.png b/assets/icons/reply-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..fabe1b05c3382eadb98561cc8b568af74e9c849d GIT binary patch literal 912 zcmV;B18@9^P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmYLwx`MLwy0jcT;@;00QGlL_t(&-tC!BNK`=_$3N=srmF@CDoJESS(FF`b<#W( z{W%r}MPSgSZc-gObPnrW5YnZKQXV5~sW4Ew1{GRj7FtnJiKXVUYrYP%ul&88_a5up z***Avb6DoLGxPn-ym{}w782$xJKHTxLs0o6Vb_6@xZvaT?VLf%9j;T-ooNOWfGvfpz;(0P+@GGzyRwwU}-N(m4zl6hONIg#?Hd8z8d+^6mV`D1h8y8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{Lm`COAwT$KA%qz+2MQC1vvwu9wVJ6AAh0Iub&7GK8?V z%{03v)5m!sgl*l(-Gb~2A*>3KIVo?&NS0CDE?G9SM3UmM%j0GE2G?N|7Pb9cdZ4wqyM=aRlFRIM z;tyncN-qRxCHUX*Fh1|W@!O(`6=7fF0ew<|Ui6`8(el~1aicy7p5g+WXtVuEticn~ zRi1r8(IN0_8*LBbQG8PHSUsg^2DEb5NU}0(xjqe^;sSgjS(FsxUCHI=PX&)r3Z1+e zdPovvBM0#e9yb7sEs9 - - - - - \ 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 0000000000000000000000000000000000000000..6573f8f136805cb3e1be0b6d111c427f07078dc7 GIT binary patch literal 808 zcmV+@1K0eCP)@~0drDELIAGL9O(c600d`2O+f$vv5yPp9$!k1c3G6^v7 z3V?1Oe&?-*M9}Tx@?KuYt22CyQCke}`>%bTxE#jt7B>G@4^W`eayX}OW;GzdUbt@! z%4i926)1Qaxqb(3cP3OJ4nRmd!_$PQrXtdkW2rz9bUiUd1DQyJARjWwiSER>r~SBJ zpvyNQJ-g0gXw1L2(YRUyyoLQK;)7p}oPY{n&l{b!kbkWzHdSzo337XuaV zG4H6`x&JjfR0zqBIU&;0$L&e-5!@7XgbaM^@k6{%yycJgb(rA4MH)iuRZtT6a@E&B miFgrIkHr{(VP)z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;(K){{a7>y{D4^000SaNLh0L04^f{04^f|c%?sf00007 zbV*G`2k8e00T?&2Z$oqd00RR_L_t(|+U=RYPZU8E$KQ9BEV~=RU9vGNCTOd)m#DE> zq0!dlP6`?;Vr=Z_WE1`a8zV*&L&^OCU^I3nDg~87DKa&PW9 zeV=5Ty_+}lzWd&r-8V!G!!QiPFbu;m{~;*y=h4y8E1gc~H4$AVqBl~?M@7b0DwXQN z!NFr9nkqVXj1Cd~0PwL|t**CPt>4;}vMg&7KuARL_yVvI1VJuGYPH%3fX$QRdvO8S z6GANbzHexA-f8f=TCHuriWU9moo5l!oJYZe z^hrv2U2*>x5q+SebNe!#ov-8L<4^bZ_uEM#EG;cPmr~9bSo5}JSuvsw$ zMA(Rp4=u}@%pK8Xgm7JVtle(k?RL92iRdC7o!e_Gf+=bFjEL?K(Rb4{9~>SY?hwN; h48t%C!!Qh!%pZ5A!Hl{MJmdfX002ovPDHLkV1lD}mw^BP diff --git a/assets/icons/repost_light_4x.png b/assets/icons/repost_light_4x.png new file mode 100644 index 0000000000000000000000000000000000000000..67646de70ab8114a9c7acf0f742dfd86df4d49f9 GIT binary patch literal 1145 zcmV-<1cv*GP)@~0drDELIAGL9O(c600d`2O+f$vv5yPQ1e6m1Cm^h5Ik1}@VFO4kD7)EBMsNUT z+4432Ck3el+p(Pht>T|lC5=B~Kiluw?}fWL^70=-=+$bqM z`~552dXl=j5a4Uig7fq9t7vpUIe{tsJuMF_JzQ2PodaE^XeEHS@?H8s@Xj`b)YZ)1V9UVEB`u?s z0HEmBDf_g41sZ%POJji}-BjQnbj8oKOjZKGNVF+OP~VQs62zTnbEjol68KoEO2HXh zfu#L?RavPNpfkt#Y1`s@z1~x4f2{i}HgS}V&iVQIo+!b1AHcR=^qf17Q8co_Y4GUf z(0OJXf(+5VUNXUW38160skl!$!ZQt*Ey{-m1bHAzFcttR@62X!PDMu7D@h=%7Tmtv^_v}xz`sPN!K7<-lzHEvfnna{tkcP%$rI#rJ z%rgnrV^)^V$`NjC?Z^)=B}ArHWUh5{5? z3Pu&{e@8mDyG^aLKwP;_==(?(ff)uf;FNNLBS2WHM`VfiVTfNMi?78*ST0)M2h?h{ zJ;h!_mk<_YHjV&UWBi2(6j&fw!;x;>E>Tw-+h;a|Uo?yS!+ZE$y}b4o#sXm5Js1p5 zhPS;o_IFe;_6M+1j6>8B|L0{fuAR>WADZ|xS#mfW4u`|x7*qZORgc+Q00AQ&00000 LNkvXXu0mjfQQ{2v literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..cc231965043f8dc83cff11edcbd986509b59cb00 GIT binary patch literal 866 zcmV-o1D*VdP)@~0drDELIAGL9O(c600d`2O+f$vv5yP1LSx`hJA$mJI zy4?yP--WVQsEGulHGN#ml&_%{5{$MV#B$Uz2RWmmysUZgVnft12Vs1T=E}?<{)UND zor4^gN+D*nFW$DAi&dS29N7tBg3$tJ1cr&Vpv=ddU`pnWZjBJ~K*{_L{M|6|*VN_) z#$(-;b=ZO#MhnzEU>VZ3@|a;Xrhbcsh@Q(~H&3_@8z#iUxdi++5DJkZgP$r-JIM6g@4ZRq+0<5~At`ah41z1dDWu@lsh>ljy|6_R;@ znMmkc>sQEHqm{-z%&flQ`8NYYjx#6o17%KQYBi`}=++8tzJku~(y9Iz2_?BL>}=Zz zA@|hY-mkR9vTPwOncGM^4Og*rLTy4aqS1)6BeUVeTKcfUNQKx90k;9OxCEp5Aiq95pn}nggZvyM(c*}&Sf4N=RsCbY$T;z-%V<6*%s~Mfs2xoIMTx4>rW`{l`+jVe+iCugQ4nZ6951J07*qoM6N<$f=PskRsaA1 literal 0 HcmV?d00001 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();