1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-26 08:29:26 +00:00

feat(core/ui): make Delizia subtitle adjust to longer text

[no changelog]
This commit is contained in:
Ioan Bizău 2025-03-19 11:39:08 +01:00 committed by Ioan Bizău
parent 83b86298bf
commit 926e2225b5
3 changed files with 23 additions and 16 deletions

View File

@ -410,13 +410,11 @@ fn frame_place(
bounds: Rect, bounds: Rect,
margin: usize, margin: usize,
) -> Rect { ) -> Rect {
let (mut header_area, mut content_area) = bounds.split_top(TITLE_HEIGHT); let header_area = header.place(bounds);
content_area = content_area let mut content_area = bounds
.inset(Insets::top(header_area.height().max(TITLE_HEIGHT)))
.inset(Insets::top(theme::SPACING)) .inset(Insets::top(theme::SPACING))
.inset(Insets::top(margin as i16)); .inset(Insets::top(margin as i16));
header_area = header_area.inset(Insets::sides(theme::SPACING));
header.place(header_area);
if let Some(footer) = footer { if let Some(footer) = footer {
// FIXME: spacer at the bottom might be applied also for usage without footer // FIXME: spacer at the bottom might be applied also for usage without footer

View File

@ -93,7 +93,7 @@ impl Header {
pub const fn new(alignment: Alignment, title: TString<'static>) -> Self { pub const fn new(alignment: Alignment, title: TString<'static>) -> Self {
Self { Self {
area: Rect::zero(), area: Rect::zero(),
title: Label::new(title, alignment, theme::label_title_main()).vertically_centered(), title: Label::new(title, alignment, theme::label_title_main()),
subtitle: None, subtitle: None,
button: None, button: None,
anim: None, anim: None,
@ -185,23 +185,32 @@ impl Component for Header {
fn place(&mut self, bounds: Rect) -> Rect { fn place(&mut self, bounds: Rect) -> Rect {
let header_area = if let Some(b) = &mut self.button { let header_area = if let Some(b) = &mut self.button {
let (rest, button_area) = bounds.split_right(TITLE_HEIGHT); let (rest, button_area) = bounds.split_right(TITLE_HEIGHT + theme::SPACING * 2);
let (button_area, _under_button_area) = button_area.split_top(TITLE_HEIGHT);
b.place(button_area); b.place(button_area);
rest rest
} else { } else {
bounds bounds
}; }
.inset(Insets::sides(theme::SPACING));
if self.subtitle.is_some() { if self.subtitle.is_some() {
let title_area = self.title.place(header_area); let title_area = self.title.place(header_area);
let remaining = header_area.inset(Insets::top(title_area.height())); let remaining = header_area.inset(Insets::top(title_area.height()));
let _subtitle_area = self.subtitle.place(remaining); let subtitle_area = self.subtitle.place(remaining);
self.area = title_area.outset(Insets::top(subtitle_area.height()));
} else { } else {
self.title.place(header_area); let title_area = self.title.place(header_area);
if title_area.height() < header_area.height() / 10 {
self.title
.place(title_area.translate(Offset::y(title_area.height() / 2)));
} else {
self.title
.place(title_area.translate(Offset::y(-theme::SPACING)));
} }
};
self.area = bounds; self.area
bounds
} }
fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> { fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
@ -238,7 +247,7 @@ impl Component for Header {
self.button.render(target); self.button.render(target);
target.in_clip(self.area.split_left(offset.x).0, &|target| { target.in_clip(self.title.area().split_left(offset.x).0, &|target| {
if let Some(icon) = self.icon { if let Some(icon) = self.icon {
let color = self.color.unwrap_or(theme::GREEN); let color = self.color.unwrap_or(theme::GREEN);
shape::ToifImage::new(self.title.area().left_center(), icon.toif) shape::ToifImage::new(self.title.area().left_center(), icon.toif)

View File

@ -190,7 +190,7 @@ async def confirm_path_payment_strict_receive_op(
await confirm_output( await confirm_output(
op.destination_account, op.destination_account,
format_amount(op.destination_amount, op.destination_asset), format_amount(op.destination_amount, op.destination_asset),
title=TR.stellar__path_pay, TR.stellar__path_pay,
) )
await confirm_asset_issuer(op.destination_asset) await confirm_asset_issuer(op.destination_asset)
# confirm what the sender is using to pay # confirm what the sender is using to pay
@ -209,7 +209,7 @@ async def confirm_path_payment_strict_send_op(
await confirm_output( await confirm_output(
op.destination_account, op.destination_account,
format_amount(op.destination_min, op.destination_asset), format_amount(op.destination_min, op.destination_asset),
title=TR.stellar__path_pay_at_least, TR.stellar__path_pay_at_least,
) )
await confirm_asset_issuer(op.destination_asset) await confirm_asset_issuer(op.destination_asset)
# confirm what the sender is using to pay # confirm what the sender is using to pay