mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-20 12:21:01 +00:00
refactor(core/rust): replace Label::new with alignment-specific constructor
[no changelog]
This commit is contained in:
parent
c04cd19c6c
commit
3f6a55cc3a
@ -36,8 +36,8 @@ where
|
|||||||
Self::new(text, Alignment::Center, style)
|
Self::new(text, Alignment::Center, style)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vertically_aligned(mut self, align: Alignment) -> Self {
|
pub fn vertically_centered(mut self) -> Self {
|
||||||
self.vertical = align;
|
self.vertical = Alignment::Center;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ impl<T: StringType + Clone> FormattedText<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vertically_aligned(mut self, align: Alignment) -> Self {
|
pub fn vertically_centered(mut self) -> Self {
|
||||||
self.vertical = align;
|
self.vertical = Alignment::Center;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
component::{Child, Component, Event, EventCtx, Label, Pad},
|
component::{Child, Component, Event, EventCtx, Label, Pad},
|
||||||
geometry::{Alignment, Alignment2D, Rect},
|
geometry::{Alignment2D, Rect},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@ -38,18 +38,12 @@ impl<'a> Intro<'a> {
|
|||||||
pub fn new(title: &'a str, content: &'a str) -> Self {
|
pub fn new(title: &'a str, content: &'a str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
bg: Pad::with_background(BLD_BG).with_clear(),
|
bg: Pad::with_background(BLD_BG).with_clear(),
|
||||||
title: Child::new(
|
title: Child::new(Label::centered(title, TEXT_NORMAL).vertically_centered()),
|
||||||
Label::new(title, Alignment::Center, TEXT_NORMAL)
|
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
buttons: Child::new(ButtonController::new(ButtonLayout::text_none_text(
|
buttons: Child::new(ButtonController::new(ButtonLayout::text_none_text(
|
||||||
LEFT_BUTTON_TEXT,
|
LEFT_BUTTON_TEXT,
|
||||||
RIGHT_BUTTON_TEXT,
|
RIGHT_BUTTON_TEXT,
|
||||||
))),
|
))),
|
||||||
text: Child::new(
|
text: Child::new(Label::left_aligned(content, TEXT_NORMAL).vertically_centered()),
|
||||||
Label::new(content, Alignment::Start, TEXT_NORMAL)
|
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
constant::SCREEN,
|
constant::SCREEN,
|
||||||
display::{self, Color, Font, Icon},
|
display::{self, Color, Font, Icon},
|
||||||
event::ButtonEvent,
|
event::ButtonEvent,
|
||||||
geometry::{Alignment, Alignment::Center, Alignment2D, Offset, Rect},
|
geometry::{Alignment2D, Offset, Rect},
|
||||||
util::{from_c_array, from_c_str},
|
util::{from_c_array, from_c_str},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -137,18 +137,16 @@ extern "C" fn screen_install_confirm(
|
|||||||
"DOWNGRADE FW"
|
"DOWNGRADE FW"
|
||||||
};
|
};
|
||||||
|
|
||||||
let message = Label::new(version_str.as_str(), Alignment::Start, theme::TEXT_NORMAL)
|
let message =
|
||||||
.vertically_aligned(Center);
|
Label::left_aligned(version_str.as_str(), theme::TEXT_NORMAL).vertically_centered();
|
||||||
let fingerprint = Label::new(
|
let fingerprint = Label::left_aligned(
|
||||||
fingerprint_str,
|
fingerprint_str,
|
||||||
Alignment::Start,
|
|
||||||
theme::TEXT_NORMAL.with_line_breaking(BreakWordsNoHyphen),
|
theme::TEXT_NORMAL.with_line_breaking(BreakWordsNoHyphen),
|
||||||
)
|
)
|
||||||
.vertically_aligned(Center);
|
.vertically_centered();
|
||||||
|
|
||||||
let alert = (!should_keep_seed).then_some(Label::new(
|
let alert = (!should_keep_seed).then_some(Label::left_aligned(
|
||||||
"Seed will be erased!",
|
"Seed will be erased!",
|
||||||
Alignment::Start,
|
|
||||||
theme::TEXT_NORMAL,
|
theme::TEXT_NORMAL,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -159,12 +157,8 @@ extern "C" fn screen_install_confirm(
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn screen_wipe_confirm() -> u32 {
|
extern "C" fn screen_wipe_confirm() -> u32 {
|
||||||
let message = Label::new(
|
let message = Label::left_aligned("Seed and firmware will be erased!", theme::TEXT_NORMAL)
|
||||||
"Seed and firmware will be erased!",
|
.vertically_centered();
|
||||||
Alignment::Start,
|
|
||||||
theme::TEXT_NORMAL,
|
|
||||||
)
|
|
||||||
.vertically_aligned(Center);
|
|
||||||
|
|
||||||
let mut frame = Confirm::new(BLD_BG, "FACTORY RESET", message, None, "RESET");
|
let mut frame = Confirm::new(BLD_BG, "FACTORY RESET", message, None, "RESET");
|
||||||
|
|
||||||
@ -278,15 +272,10 @@ extern "C" fn screen_connect() {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn screen_wipe_success() {
|
extern "C" fn screen_wipe_success() {
|
||||||
let title = Label::new("Trezor Reset", Alignment::Center, theme::TEXT_BOLD)
|
let title = Label::centered("Trezor Reset", theme::TEXT_BOLD).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let content = Label::new(
|
let content =
|
||||||
"Reconnect\nthe device",
|
Label::centered("Reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered();
|
||||||
Alignment::Center,
|
|
||||||
theme::TEXT_NORMAL,
|
|
||||||
)
|
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, true);
|
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, true);
|
||||||
show(&mut frame);
|
show(&mut frame);
|
||||||
@ -294,15 +283,10 @@ extern "C" fn screen_wipe_success() {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn screen_wipe_fail() {
|
extern "C" fn screen_wipe_fail() {
|
||||||
let title = Label::new("Reset failed", Alignment::Center, theme::TEXT_BOLD)
|
let title = Label::centered("Reset failed", theme::TEXT_BOLD).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let content = Label::new(
|
let content =
|
||||||
"Please reconnect\nthe device",
|
Label::centered("Please reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered();
|
||||||
Alignment::Center,
|
|
||||||
theme::TEXT_NORMAL,
|
|
||||||
)
|
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_ALERT, title, content, true);
|
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_ALERT, title, content, true);
|
||||||
show(&mut frame);
|
show(&mut frame);
|
||||||
@ -325,15 +309,10 @@ extern "C" fn screen_boot_empty(_firmware_present: bool) {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn screen_install_fail() {
|
extern "C" fn screen_install_fail() {
|
||||||
let title = Label::new("Install failed", Alignment::Center, theme::TEXT_BOLD)
|
let title = Label::centered("Install failed", theme::TEXT_BOLD).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let content = Label::new(
|
let content =
|
||||||
"Please reconnect\nthe device",
|
Label::centered("Please reconnect\nthe device", theme::TEXT_NORMAL).vertically_centered();
|
||||||
Alignment::Center,
|
|
||||||
theme::TEXT_NORMAL,
|
|
||||||
)
|
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_ALERT, title, content, true);
|
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_ALERT, title, content, true);
|
||||||
show(&mut frame);
|
show(&mut frame);
|
||||||
@ -347,11 +326,9 @@ extern "C" fn screen_install_success(
|
|||||||
) {
|
) {
|
||||||
let msg = unwrap!(unsafe { from_c_str(reboot_msg) });
|
let msg = unwrap!(unsafe { from_c_str(reboot_msg) });
|
||||||
|
|
||||||
let title = Label::new("Firmware installed", Alignment::Center, theme::TEXT_BOLD)
|
let title = Label::centered("Firmware installed", theme::TEXT_BOLD).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let content = Label::new(msg, Alignment::Center, theme::TEXT_NORMAL)
|
let content = Label::centered(msg, theme::TEXT_NORMAL).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
|
|
||||||
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, complete_draw);
|
let mut frame = ResultScreen::new(BLD_FG, BLD_BG, ICON_SPINNER, title, content, complete_draw);
|
||||||
show(&mut frame);
|
show(&mut frame);
|
||||||
|
@ -2,7 +2,7 @@ use crate::ui::{
|
|||||||
component::{Child, Component, Event, EventCtx, Label, Never, Pad},
|
component::{Child, Component, Event, EventCtx, Label, Never, Pad},
|
||||||
constant::screen,
|
constant::screen,
|
||||||
display,
|
display,
|
||||||
geometry::{Alignment::Center, Alignment2D, Offset, Point, Rect},
|
geometry::{Alignment2D, Offset, Point, Rect},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
@ -25,9 +25,9 @@ pub struct ErrorScreen<T> {
|
|||||||
|
|
||||||
impl<T: AsRef<str>> ErrorScreen<T> {
|
impl<T: AsRef<str>> ErrorScreen<T> {
|
||||||
pub fn new(title: T, message: T, footer: T) -> Self {
|
pub fn new(title: T, message: T, footer: T) -> Self {
|
||||||
let title = Label::new(title, Center, theme::TEXT_BOLD);
|
let title = Label::centered(title, theme::TEXT_BOLD);
|
||||||
let message = Label::new(message, Center, theme::TEXT_NORMAL).vertically_aligned(Center);
|
let message = Label::centered(message, theme::TEXT_NORMAL).vertically_centered();
|
||||||
let footer = Label::new(footer, Center, theme::TEXT_NORMAL).vertically_aligned(Center);
|
let footer = Label::centered(footer, theme::TEXT_NORMAL).vertically_centered();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
bg: Pad::with_background(BG).with_clear(),
|
bg: Pad::with_background(BG).with_clear(),
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
constant::screen,
|
constant::screen,
|
||||||
display::toif::Icon,
|
display::toif::Icon,
|
||||||
geometry::{Alignment, Insets, LinearPlacement, Rect},
|
geometry::{Insets, LinearPlacement, Rect},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ where
|
|||||||
area: Rect::zero(),
|
area: Rect::zero(),
|
||||||
pad,
|
pad,
|
||||||
result_anim: Child::new(ResultAnim::new(icon)),
|
result_anim: Child::new(ResultAnim::new(icon)),
|
||||||
headline: headline.map(|a| Label::new(a, Alignment::Center, theme::TEXT_BOLD)),
|
headline: headline.map(|a| Label::centered(a, theme::TEXT_BOLD)),
|
||||||
text: Child::new(p1),
|
text: Child::new(p1),
|
||||||
buttons,
|
buttons,
|
||||||
autoclose: false,
|
autoclose: false,
|
||||||
|
@ -549,8 +549,7 @@ extern "C" fn new_confirm_output(n_args: usize, args: *const Obj, kwargs: *mut M
|
|||||||
ops = ops.text_normal(address_label.clone()).newline();
|
ops = ops.text_normal(address_label.clone()).newline();
|
||||||
}
|
}
|
||||||
ops = ops.text_mono(address.clone());
|
ops = ops.text_mono(address.clone());
|
||||||
let formatted =
|
let formatted = FormattedText::new(ops).vertically_centered();
|
||||||
FormattedText::new(ops).vertically_aligned(geometry::Alignment::Center);
|
|
||||||
Page::new(btn_layout, btn_actions, formatted).with_title(address_title.clone())
|
Page::new(btn_layout, btn_actions, formatted).with_title(address_title.clone())
|
||||||
}
|
}
|
||||||
1 => {
|
1 => {
|
||||||
@ -558,8 +557,7 @@ extern "C" fn new_confirm_output(n_args: usize, args: *const Obj, kwargs: *mut M
|
|||||||
let btn_layout = ButtonLayout::up_arrow_none_text("CONFIRM".into());
|
let btn_layout = ButtonLayout::up_arrow_none_text("CONFIRM".into());
|
||||||
let btn_actions = ButtonActions::prev_none_confirm();
|
let btn_actions = ButtonActions::prev_none_confirm();
|
||||||
let ops = OpTextLayout::new(theme::TEXT_MONO).text_mono(amount.clone());
|
let ops = OpTextLayout::new(theme::TEXT_MONO).text_mono(amount.clone());
|
||||||
let formatted =
|
let formatted = FormattedText::new(ops).vertically_centered();
|
||||||
FormattedText::new(ops).vertically_aligned(geometry::Alignment::Center);
|
|
||||||
Page::new(btn_layout, btn_actions, formatted).with_title(amount_title.clone())
|
Page::new(btn_layout, btn_actions, formatted).with_title(amount_title.clone())
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -3,7 +3,7 @@ use crate::ui::{
|
|||||||
constant,
|
constant,
|
||||||
constant::screen,
|
constant::screen,
|
||||||
display::{Color, Icon},
|
display::{Color, Icon},
|
||||||
geometry::{Alignment, Alignment2D, Insets, Offset, Point, Rect},
|
geometry::{Alignment2D, Insets, Offset, Point, Rect},
|
||||||
model_tt::{
|
model_tt::{
|
||||||
bootloader::theme::{
|
bootloader::theme::{
|
||||||
button_bld_menu, BUTTON_AREA_START, BUTTON_HEIGHT, CONTENT_PADDING, CORNER_BUTTON_AREA,
|
button_bld_menu, BUTTON_AREA_START, BUTTON_HEIGHT, CONTENT_PADDING, CORNER_BUTTON_AREA,
|
||||||
@ -69,19 +69,13 @@ impl<'a> Confirm<'a> {
|
|||||||
content_pad: Pad::with_background(bg_color),
|
content_pad: Pad::with_background(bg_color),
|
||||||
bg_color,
|
bg_color,
|
||||||
title,
|
title,
|
||||||
message: Child::new(message.vertically_aligned(Alignment::Center)),
|
message: Child::new(message.vertically_centered()),
|
||||||
alert: alert.map(|alert| Child::new(alert.vertically_aligned(Alignment::Center))),
|
alert: alert.map(|alert| Child::new(alert.vertically_centered())),
|
||||||
left_button: Child::new(left_button),
|
left_button: Child::new(left_button),
|
||||||
right_button: Child::new(right_button),
|
right_button: Child::new(right_button),
|
||||||
info: info.map(|(title, text)| ConfirmInfo {
|
info: info.map(|(title, text)| ConfirmInfo {
|
||||||
title: Child::new(
|
title: Child::new(Label::left_aligned(title, TEXT_TITLE).vertically_centered()),
|
||||||
Label::new(title, Alignment::Start, TEXT_TITLE)
|
text: Child::new(Label::left_aligned(text, TEXT_FINGERPRINT).vertically_centered()),
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
text: Child::new(
|
|
||||||
Label::new(text, Alignment::Start, TEXT_FINGERPRINT)
|
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
info_button: Child::new(
|
info_button: Child::new(
|
||||||
Button::with_icon(Icon::new(INFO32))
|
Button::with_icon(Icon::new(INFO32))
|
||||||
.styled(button_bld_menu())
|
.styled(button_bld_menu())
|
||||||
|
@ -2,7 +2,7 @@ use crate::ui::{
|
|||||||
component::{Child, Component, Event, EventCtx, Label, Pad},
|
component::{Child, Component, Event, EventCtx, Label, Pad},
|
||||||
constant::screen,
|
constant::screen,
|
||||||
display::Icon,
|
display::Icon,
|
||||||
geometry::{Alignment, Insets, Point, Rect},
|
geometry::{Insets, Point, Rect},
|
||||||
model_tt::{
|
model_tt::{
|
||||||
bootloader::theme::{
|
bootloader::theme::{
|
||||||
button_bld, button_bld_menu, BLD_BG, BUTTON_AREA_START, BUTTON_HEIGHT, CONTENT_PADDING,
|
button_bld, button_bld_menu, BLD_BG, BUTTON_AREA_START, BUTTON_HEIGHT, CONTENT_PADDING,
|
||||||
@ -32,20 +32,14 @@ impl<'a> Intro<'a> {
|
|||||||
pub fn new(title: &'a str, content: &'a str) -> Self {
|
pub fn new(title: &'a str, content: &'a str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
bg: Pad::with_background(BLD_BG).with_clear(),
|
bg: Pad::with_background(BLD_BG).with_clear(),
|
||||||
title: Child::new(
|
title: Child::new(Label::left_aligned(title, TEXT_TITLE).vertically_centered()),
|
||||||
Label::new(title, Alignment::Start, TEXT_TITLE)
|
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
menu: Child::new(
|
menu: Child::new(
|
||||||
Button::with_icon(Icon::new(MENU32))
|
Button::with_icon(Icon::new(MENU32))
|
||||||
.styled(button_bld_menu())
|
.styled(button_bld_menu())
|
||||||
.with_expanded_touch_area(Insets::uniform(13)),
|
.with_expanded_touch_area(Insets::uniform(13)),
|
||||||
),
|
),
|
||||||
host: Child::new(Button::with_text("INSTALL FIRMWARE").styled(button_bld())),
|
host: Child::new(Button::with_text("INSTALL FIRMWARE").styled(button_bld())),
|
||||||
text: Child::new(
|
text: Child::new(Label::left_aligned(content, TEXT_NORMAL).vertically_centered()),
|
||||||
Label::new(content, Alignment::Start, TEXT_NORMAL)
|
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use crate::ui::{
|
|||||||
component::{Child, Component, Event, EventCtx, Label, Pad},
|
component::{Child, Component, Event, EventCtx, Label, Pad},
|
||||||
constant::{screen, WIDTH},
|
constant::{screen, WIDTH},
|
||||||
display::Icon,
|
display::Icon,
|
||||||
geometry::{Alignment, Insets, Point, Rect},
|
geometry::{Insets, Point, Rect},
|
||||||
model_tt::{
|
model_tt::{
|
||||||
bootloader::theme::{
|
bootloader::theme::{
|
||||||
button_bld, button_bld_menu, BLD_BG, BUTTON_HEIGHT, CONTENT_PADDING,
|
button_bld, button_bld_menu, BLD_BG, BUTTON_HEIGHT, CONTENT_PADDING,
|
||||||
@ -39,10 +39,7 @@ impl Menu {
|
|||||||
|
|
||||||
let mut instance = Self {
|
let mut instance = Self {
|
||||||
bg: Pad::with_background(BLD_BG),
|
bg: Pad::with_background(BLD_BG),
|
||||||
title: Child::new(
|
title: Child::new(Label::left_aligned("BOOTLOADER", TEXT_TITLE).vertically_centered()),
|
||||||
Label::new("BOOTLOADER", Alignment::Start, TEXT_TITLE)
|
|
||||||
.vertically_aligned(Alignment::Center),
|
|
||||||
),
|
|
||||||
close: Child::new(
|
close: Child::new(
|
||||||
Button::with_icon(Icon::new(X32))
|
Button::with_icon(Icon::new(X32))
|
||||||
.styled(button_bld_menu())
|
.styled(button_bld_menu())
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
constant::{screen, HEIGHT},
|
constant::{screen, HEIGHT},
|
||||||
display::{self, Color, Font, Icon},
|
display::{self, Color, Font, Icon},
|
||||||
event::TouchEvent,
|
event::TouchEvent,
|
||||||
geometry::{Alignment, Alignment2D, Point},
|
geometry::{Alignment2D, Point},
|
||||||
model_tt::{
|
model_tt::{
|
||||||
bootloader::{
|
bootloader::{
|
||||||
confirm::ConfirmTitle,
|
confirm::ConfirmTitle,
|
||||||
@ -162,12 +162,10 @@ extern "C" fn screen_install_confirm(
|
|||||||
} else {
|
} else {
|
||||||
"DOWNGRADE FW"
|
"DOWNGRADE FW"
|
||||||
};
|
};
|
||||||
let title = Label::new(title_str, Alignment::Start, theme::TEXT_BOLD)
|
let title = Label::left_aligned(title_str, theme::TEXT_BOLD).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
let msg = Label::left_aligned(version_str.as_ref(), theme::TEXT_NORMAL);
|
||||||
let msg = Label::new(version_str.as_ref(), Alignment::Start, theme::TEXT_NORMAL);
|
let alert = (!should_keep_seed).then_some(Label::left_aligned(
|
||||||
let alert = (!should_keep_seed).then_some(Label::new(
|
|
||||||
"SEED WILL BE ERASED!",
|
"SEED WILL BE ERASED!",
|
||||||
Alignment::Start,
|
|
||||||
theme::TEXT_BOLD,
|
theme::TEXT_BOLD,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -198,16 +196,11 @@ extern "C" fn screen_install_confirm(
|
|||||||
extern "C" fn screen_wipe_confirm() -> u32 {
|
extern "C" fn screen_wipe_confirm() -> u32 {
|
||||||
let icon = Icon::new(FIRE40);
|
let icon = Icon::new(FIRE40);
|
||||||
|
|
||||||
let msg = Label::new(
|
let msg = Label::centered(
|
||||||
"Are you sure you want to factory reset the device?",
|
"Are you sure you want to factory reset the device?",
|
||||||
Alignment::Center,
|
|
||||||
TEXT_WIPE_NORMAL,
|
TEXT_WIPE_NORMAL,
|
||||||
);
|
);
|
||||||
let alert = Label::new(
|
let alert = Label::centered("SEED AND FIRMWARE\nWILL BE ERASED!", TEXT_WIPE_BOLD);
|
||||||
"SEED AND FIRMWARE\nWILL BE ERASED!",
|
|
||||||
Alignment::Center,
|
|
||||||
TEXT_WIPE_BOLD,
|
|
||||||
);
|
|
||||||
|
|
||||||
let right = Button::with_text("RESET").styled(button_wipe_confirm());
|
let right = Button::with_text("RESET").styled(button_wipe_confirm());
|
||||||
let left = Button::with_text("CANCEL").styled(button_wipe_cancel());
|
let left = Button::with_text("CANCEL").styled(button_wipe_cancel());
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
Split,
|
Split,
|
||||||
},
|
},
|
||||||
display::loader::{loader_circular_uncompress, LoaderDimensions},
|
display::loader::{loader_circular_uncompress, LoaderDimensions},
|
||||||
geometry::{Alignment, Insets, Rect},
|
geometry::{Insets, Rect},
|
||||||
util::animation_disabled,
|
util::animation_disabled,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -43,8 +43,7 @@ where
|
|||||||
T: AsRef<str>,
|
T: AsRef<str>,
|
||||||
{
|
{
|
||||||
let style = theme::label_coinjoin_progress();
|
let style = theme::label_coinjoin_progress();
|
||||||
let label = Label::centered("DO NOT DISCONNECT YOUR TREZOR!", style)
|
let label = Label::centered("DO NOT DISCONNECT YOUR TREZOR!", style).vertically_centered();
|
||||||
.vertically_aligned(Alignment::Center);
|
|
||||||
let bg = painter::rect_painter(style.background_color, theme::BG);
|
let bg = painter::rect_painter(style.background_color, theme::BG);
|
||||||
let inner = (bg, label);
|
let inner = (bg, label);
|
||||||
CoinJoinProgress::with_background(text, inner, indeterminate)
|
CoinJoinProgress::with_background(text, inner, indeterminate)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
component::{Child, Component, Event, EventCtx, Label, Never, Pad},
|
component::{Child, Component, Event, EventCtx, Label, Never, Pad},
|
||||||
constant::screen,
|
constant::screen,
|
||||||
geometry::{Alignment::Center, Alignment2D, Point, Rect},
|
geometry::{Alignment2D, Point, Rect},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::ui::model_tt::{
|
use crate::ui::model_tt::{
|
||||||
@ -28,8 +28,8 @@ pub struct ErrorScreen<'a, T> {
|
|||||||
|
|
||||||
impl<T: AsRef<str>> ErrorScreen<'_, T> {
|
impl<T: AsRef<str>> ErrorScreen<'_, T> {
|
||||||
pub fn new(title: T, message: T, footer: T) -> Self {
|
pub fn new(title: T, message: T, footer: T) -> Self {
|
||||||
let title = Label::new(title, Center, STYLE.title_style());
|
let title = Label::centered(title, STYLE.title_style());
|
||||||
let message = Label::new(message, Center, STYLE.message_style());
|
let message = Label::centered(message, STYLE.message_style());
|
||||||
let footer = ResultFooter::new(footer, STYLE);
|
let footer = ResultFooter::new(footer, STYLE);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
component::{image::Image, Child, Component, Event, EventCtx, Label},
|
component::{image::Image, Child, Component, Event, EventCtx, Label},
|
||||||
display,
|
display,
|
||||||
geometry::{Alignment, Insets, Rect},
|
geometry::{Insets, Rect},
|
||||||
model_tt::component::{
|
model_tt::component::{
|
||||||
fido_icons::get_fido_icon_data,
|
fido_icons::get_fido_icon_data,
|
||||||
swipe::{Swipe, SwipeDirection},
|
swipe::{Swipe, SwipeDirection},
|
||||||
@ -60,8 +60,8 @@ where
|
|||||||
page_swipe.allow_left = scrollbar.has_next_page();
|
page_swipe.allow_left = scrollbar.has_next_page();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_name: Label::new(app_name, Alignment::Center, theme::TEXT_DEMIBOLD),
|
app_name: Label::centered(app_name, theme::TEXT_DEMIBOLD),
|
||||||
account_name: Label::new("".into(), Alignment::Center, theme::TEXT_DEMIBOLD),
|
account_name: Label::centered("".into(), theme::TEXT_DEMIBOLD),
|
||||||
page_swipe,
|
page_swipe,
|
||||||
icon: Child::new(Image::new(icon_data)),
|
icon: Child::new(Image::new(icon_data)),
|
||||||
get_account,
|
get_account,
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
component::{text::TextStyle, Child, Component, Event, EventCtx, Label, Never, Pad},
|
component::{text::TextStyle, Child, Component, Event, EventCtx, Label, Never, Pad},
|
||||||
constant::screen,
|
constant::screen,
|
||||||
display::{self, Color, Font, Icon},
|
display::{self, Color, Font, Icon},
|
||||||
geometry::{Alignment::Center, Alignment2D, Insets, Offset, Point, Rect},
|
geometry::{Alignment2D, Insets, Offset, Point, Rect},
|
||||||
model_tt::theme::FG,
|
model_tt::theme::FG,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -51,7 +51,7 @@ impl<'a, T: AsRef<str>> ResultFooter<'a, T> {
|
|||||||
pub fn new(text: T, style: &'a ResultStyle) -> Self {
|
pub fn new(text: T, style: &'a ResultStyle) -> Self {
|
||||||
Self {
|
Self {
|
||||||
style,
|
style,
|
||||||
text: Label::new(text, Center, style.title_style()).vertically_aligned(Center),
|
text: Label::centered(text, style.title_style()).vertically_centered(),
|
||||||
area: Rect::zero(),
|
area: Rect::zero(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ impl<'a, T: StringType> ResultScreen<'a, T> {
|
|||||||
footer_pad: Pad::with_background(style.bg_color),
|
footer_pad: Pad::with_background(style.bg_color),
|
||||||
style,
|
style,
|
||||||
icon,
|
icon,
|
||||||
message: Child::new(Label::new(message, Center, style.message_style())),
|
message: Child::new(Label::centered(message, style.message_style())),
|
||||||
footer: Child::new(ResultFooter::new(footer, style)),
|
footer: Child::new(ResultFooter::new(footer, style)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ extern "C" fn new_confirm_emphasized(n_args: usize, args: *const Obj, kwargs: *m
|
|||||||
theme::label_title(),
|
theme::label_title(),
|
||||||
title,
|
title,
|
||||||
SwipePage::new(
|
SwipePage::new(
|
||||||
FormattedText::new(ops).vertically_aligned(geometry::Alignment::Center),
|
FormattedText::new(ops).vertically_centered(),
|
||||||
buttons,
|
buttons,
|
||||||
theme::BG,
|
theme::BG,
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user