ui/note: fix indented actionbar in non-wide mode
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
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
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -454,20 +454,28 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
note_action = contents.action.or(note_action);
|
note_action = contents.action.or(note_action);
|
||||||
|
|
||||||
if self.options().contains(NoteOptions::ActionBar) {
|
if self.options().contains(NoteOptions::ActionBar) {
|
||||||
note_action = render_note_actionbar(
|
note_action = ui
|
||||||
ui,
|
.horizontal_wrapped(|ui| {
|
||||||
get_zapper(
|
// NOTE(jb55): without this we get a weird artifact where
|
||||||
self.note_context.accounts,
|
// there subsequent lines start sinking leftward off the screen.
|
||||||
self.note_context.global_wallet,
|
// question: WTF? question 2: WHY?
|
||||||
self.note_context.zaps,
|
ui.allocate_space(egui::vec2(0.0, 0.0));
|
||||||
),
|
|
||||||
self.note.id(),
|
render_note_actionbar(
|
||||||
self.note.pubkey(),
|
ui,
|
||||||
note_key,
|
get_zapper(
|
||||||
self.note_context.i18n,
|
self.note_context.accounts,
|
||||||
)
|
self.note_context.global_wallet,
|
||||||
.inner
|
self.note_context.zaps,
|
||||||
.or(note_action);
|
),
|
||||||
|
self.note.id(),
|
||||||
|
self.note.pubkey(),
|
||||||
|
note_key,
|
||||||
|
self.note_context.i18n,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.inner
|
||||||
|
.or(note_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
NoteUiResponse {
|
NoteUiResponse {
|
||||||
@@ -531,20 +539,23 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
note_action = contents.action.or(note_action);
|
note_action = contents.action.or(note_action);
|
||||||
|
|
||||||
if self.options().contains(NoteOptions::ActionBar) {
|
if self.options().contains(NoteOptions::ActionBar) {
|
||||||
note_action = render_note_actionbar(
|
note_action = ui
|
||||||
ui,
|
.horizontal_wrapped(|ui| {
|
||||||
get_zapper(
|
render_note_actionbar(
|
||||||
self.note_context.accounts,
|
ui,
|
||||||
self.note_context.global_wallet,
|
get_zapper(
|
||||||
self.note_context.zaps,
|
self.note_context.accounts,
|
||||||
),
|
self.note_context.global_wallet,
|
||||||
self.note.id(),
|
self.note_context.zaps,
|
||||||
self.note.pubkey(),
|
),
|
||||||
note_key,
|
self.note.id(),
|
||||||
self.note_context.i18n,
|
self.note.pubkey(),
|
||||||
)
|
note_key,
|
||||||
.inner
|
self.note_context.i18n,
|
||||||
.or(note_action);
|
)
|
||||||
|
})
|
||||||
|
.inner
|
||||||
|
.or(note_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
NoteUiResponse {
|
NoteUiResponse {
|
||||||
@@ -781,76 +792,68 @@ fn render_note_actionbar(
|
|||||||
note_pubkey: &[u8; 32],
|
note_pubkey: &[u8; 32],
|
||||||
note_key: NoteKey,
|
note_key: NoteKey,
|
||||||
i18n: &mut Localization,
|
i18n: &mut Localization,
|
||||||
) -> egui::InnerResponse<Option<NoteAction>> {
|
) -> Option<NoteAction> {
|
||||||
ui.horizontal(|ui| {
|
ui.set_min_height(26.0);
|
||||||
// NOTE(jb55): without this we get a weird artifact where
|
ui.spacing_mut().item_spacing.x = 24.0;
|
||||||
// there subsequent lines start sinking leftward off the screen.
|
|
||||||
// question: WTF? question 2: WHY?
|
|
||||||
ui.allocate_space(egui::vec2(0.0, 0.0));
|
|
||||||
|
|
||||||
ui.set_min_height(26.0);
|
let reply_resp =
|
||||||
ui.spacing_mut().item_spacing.x = 24.0;
|
reply_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||||
|
|
||||||
let reply_resp =
|
let quote_resp =
|
||||||
reply_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
|
quote_repost_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||||
|
|
||||||
let quote_resp =
|
let to_noteid = |id: &[u8; 32]| NoteId::new(*id);
|
||||||
quote_repost_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
|
if reply_resp.clicked() {
|
||||||
|
return Some(NoteAction::Reply(to_noteid(note_id)));
|
||||||
|
}
|
||||||
|
|
||||||
let to_noteid = |id: &[u8; 32]| NoteId::new(*id);
|
if quote_resp.clicked() {
|
||||||
if reply_resp.clicked() {
|
return Some(NoteAction::Quote(to_noteid(note_id)));
|
||||||
return Some(NoteAction::Reply(to_noteid(note_id)));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if quote_resp.clicked() {
|
let Zapper { zaps, cur_acc } = zapper?;
|
||||||
return Some(NoteAction::Quote(to_noteid(note_id)));
|
|
||||||
}
|
|
||||||
|
|
||||||
let Zapper { zaps, cur_acc } = zapper?;
|
let zap_target = ZapTarget::Note(NoteZapTarget {
|
||||||
|
note_id,
|
||||||
|
zap_recipient: note_pubkey,
|
||||||
|
});
|
||||||
|
|
||||||
let zap_target = ZapTarget::Note(NoteZapTarget {
|
let zap_state = zaps.any_zap_state_for(cur_acc.pubkey.bytes(), zap_target);
|
||||||
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),
|
||||||
|
};
|
||||||
|
|
||||||
let target = NoteZapTargetOwned {
|
if zap_state.is_err() {
|
||||||
note_id: to_noteid(note_id),
|
return Some(NoteAction::Zap(ZapAction::ClearError(target)));
|
||||||
zap_recipient: Pubkey::new(*note_pubkey),
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if zap_state.is_err() {
|
let zap_resp = {
|
||||||
return Some(NoteAction::Zap(ZapAction::ClearError(target)));
|
cur_acc.secret_key.as_ref()?;
|
||||||
}
|
|
||||||
|
|
||||||
let zap_resp = {
|
match zap_state {
|
||||||
cur_acc.secret_key.as_ref()?;
|
Ok(any_zap_state) => ui.add(zap_button(i18n, any_zap_state, note_id)),
|
||||||
|
Err(err) => {
|
||||||
match zap_state {
|
let (rect, _) = ui.allocate_at_least(egui::vec2(10.0, 10.0), egui::Sense::click());
|
||||||
Ok(any_zap_state) => ui.add(zap_button(i18n, any_zap_state, note_id)),
|
ui.add(x_button(rect)).on_hover_text(err.to_string())
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
}
|
||||||
|
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||||
|
|
||||||
if zap_resp.secondary_clicked() {
|
if zap_resp.secondary_clicked() {
|
||||||
return Some(NoteAction::Zap(ZapAction::CustomizeAmount(target)));
|
return Some(NoteAction::Zap(ZapAction::CustomizeAmount(target)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !zap_resp.clicked() {
|
if !zap_resp.clicked() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount {
|
Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount {
|
||||||
target,
|
target,
|
||||||
specified_msats: None,
|
specified_msats: None,
|
||||||
})))
|
})))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[profiling::function]
|
#[profiling::function]
|
||||||
|
|||||||
Reference in New Issue
Block a user