1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

fix(core/ui): T3T1 lints

[no changelog]
This commit is contained in:
Martin Milata 2024-05-02 23:07:08 +02:00
parent 5020868c2c
commit 091b51c9c4
26 changed files with 233 additions and 267 deletions

View File

@ -61,3 +61,13 @@ where
self.inner.trace(t)
}
}
#[cfg(feature = "micropython")]
mod micropython {
use crate::{error::Error, micropython::obj::Obj, ui::layout::obj::ComponentMsgObj};
impl<T: ComponentMsgObj> ComponentMsgObj for super::Border<T> {
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
self.inner().msg_try_into_obj(msg)
}
}
}

View File

@ -67,3 +67,13 @@ impl crate::trace::Trace for Jpeg {
t.component("Jpeg");
}
}
#[cfg(feature = "micropython")]
mod micropython {
use crate::{error::Error, micropython::obj::Obj, ui::layout::obj::ComponentMsgObj};
impl ComponentMsgObj for super::Jpeg {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!();
}
}
}

View File

@ -189,3 +189,13 @@ impl crate::trace::Trace for Qr {
t.string("text", self.text.as_str().into());
}
}
#[cfg(feature = "micropython")]
mod micropython {
use crate::{error::Error, micropython::obj::Obj, ui::layout::obj::ComponentMsgObj};
impl ComponentMsgObj for super::Qr {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!();
}
}
}

View File

@ -160,3 +160,13 @@ impl crate::trace::Trace for FormattedText {
t.bool("fits", matches!(fit.get(), Some(LayoutFit::Fitting { .. })));
}
}
#[cfg(feature = "micropython")]
mod micropython {
use crate::{error::Error, micropython::obj::Obj, ui::layout::obj::ComponentMsgObj};
impl ComponentMsgObj for super::FormattedText {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!();
}
}
}

View File

@ -709,6 +709,16 @@ impl<'a, T: ParagraphSource<'a>> crate::trace::Trace for Checklist<T> {
}
}
#[cfg(feature = "micropython")]
mod micropython {
use crate::{error::Error, micropython::obj::Obj, ui::layout::obj::ComponentMsgObj};
impl<'a, T: super::ParagraphSource<'a>> ComponentMsgObj for super::Checklist<T> {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!();
}
}
}
pub trait VecExt<'a> {
fn add(&mut self, paragraph: Paragraph<'a>) -> &mut Self;
}

View File

@ -7,6 +7,7 @@ use crate::{
},
};
#[derive(Clone)]
pub struct Timeout {
time_ms: u32,
timer: Option<TimerToken>,

View File

@ -1,9 +1,9 @@
pub mod base;
mod flow;
pub mod page;
mod store;
mod swipe;
pub use base::{FlowMsg, FlowState, Swipable};
pub use flow::SwipeFlow;
pub use page::{IgnoreSwipe, SwipePage};
pub use store::{flow_store, FlowStore};
pub use swipe::SwipeFlow;

View File

@ -128,7 +128,7 @@ impl<Q: FlowState, S: FlowStore> SwipeFlow<Q, S> {
if finished {
self.transition = Transition::None;
}
return result;
result
}
fn handle_swipe_child(&mut self, ctx: &mut EventCtx, direction: SwipeDirection) -> Decision<Q> {

View File

@ -371,7 +371,7 @@ impl crate::trace::Trace for Button {
ButtonContent::Text(text) => t.string("text", *text),
ButtonContent::Icon(_) => t.bool("icon", true),
ButtonContent::IconAndText(content) => {
t.string("text", content.text.into());
t.string("text", content.text);
t.bool("icon", true);
}
ButtonContent::IconBlend(_, _, _) => t.bool("icon", true),

View File

@ -1,4 +1,3 @@
use super::theme;
use crate::{
strutil::TString,
ui::{
@ -11,9 +10,10 @@ use crate::{
},
};
use super::{constant::SPACING, Button, ButtonMsg, ButtonStyleSheet, CancelInfoConfirmMsg, Footer};
use super::{theme, Button, ButtonMsg, ButtonStyleSheet, CancelInfoConfirmMsg, Footer};
const TITLE_HEIGHT: i16 = 42;
const BUTTON_EXPAND_BORDER: i16 = 16;
#[derive(Clone)]
pub struct Frame<T> {
@ -84,8 +84,8 @@ where
fn with_button(mut self, icon: Icon, msg: CancelInfoConfirmMsg, enabled: bool) -> Self {
let touch_area = Insets {
left: self.border.left * 4,
bottom: self.border.bottom * 4,
left: BUTTON_EXPAND_BORDER,
bottom: BUTTON_EXPAND_BORDER,
..self.border
};
self.button = Some(Child::new(
@ -166,8 +166,8 @@ where
fn place(&mut self, bounds: Rect) -> Rect {
let (mut header_area, mut content_area) = bounds.split_top(TITLE_HEIGHT);
content_area = content_area.inset(Insets::top(SPACING));
header_area = header_area.inset(Insets::sides(SPACING));
content_area = content_area.inset(Insets::top(theme::SPACING));
header_area = header_area.inset(Insets::sides(theme::SPACING));
if let Some(b) = &mut self.button {
let (rest, button_area) = header_area.split_right(TITLE_HEIGHT);
@ -186,7 +186,7 @@ where
if let Some(footer) = &mut self.footer {
// FIXME: spacer at the bottom might be applied also for usage without footer
// but not for VerticalMenu
content_area = content_area.inset(Insets::bottom(SPACING));
content_area = content_area.inset(Insets::bottom(theme::SPACING));
let (remaining, footer_area) = content_area.split_bottom(footer.height());
footer.place(footer_area);
content_area = remaining;

View File

@ -11,6 +11,9 @@ use crate::{
use super::{theme, Button, ButtonContent, ButtonMsg};
const HOLD_DURATION_MS: u32 = 1000;
const BUTTON_SIZE: i16 = 110;
/// Component requesting an action from a user. Most typically embedded as a
/// content of a Frame and promptin "Tap to confirm" or "Hold to XYZ".
#[derive(Clone)]
@ -34,7 +37,7 @@ impl PromptScreen {
let icon = theme::ICON_SIGN;
let button = Button::new(ButtonContent::Icon(icon))
.styled(theme::button_default())
.with_long_press(Duration::from_secs(2));
.with_long_press(Duration::from_millis(HOLD_DURATION_MS));
Self {
area: Rect::zero(),
circle_color: theme::GREEN,
@ -79,7 +82,7 @@ impl Component for PromptScreen {
self.area = bounds;
self.button.place(Rect::snap(
self.area.center(),
Offset::uniform(55),
Offset::uniform(BUTTON_SIZE),
Alignment2D::CENTER,
));
bounds
@ -126,7 +129,7 @@ impl Component for PromptScreen {
.with_thickness(2)
.render(target);
});
self.button.render(target);
self.button.render_content(target, self.button.style());
}
}

View File

@ -3,11 +3,10 @@ use crate::{
strutil::TString,
translations::TR,
ui::{
component::{Component, Event, EventCtx, Paginate},
constant::SPACING,
component::{Component, Event, EventCtx, Paginate, Swipe},
flow::Swipable,
geometry::{Alignment, Alignment2D, Insets, Offset, Rect},
model_mercury::component::{Footer, Swipe, SwipeDirection},
model_mercury::component::{Footer, SwipeDirection},
shape,
shape::Renderer,
},
@ -65,8 +64,8 @@ impl<'a> Component for ShareWords<'a> {
fn place(&mut self, bounds: Rect) -> Rect {
self.area = bounds;
let used_area = bounds
.inset(Insets::sides(SPACING))
.inset(Insets::bottom(SPACING));
.inset(Insets::sides(theme::SPACING))
.inset(Insets::bottom(theme::SPACING));
self.area_word = Rect::snap(
used_area.center(),

View File

@ -90,13 +90,12 @@ impl Component for StatusScreen {
match self.dismiss_type {
DismissType::SwipeUp(ref mut swipe) => {
let swipe_dir = swipe.event(ctx, event);
match swipe_dir {
Some(SwipeDirection::Up) => return Some(()),
_ => (),
if let Some(SwipeDirection::Up) = swipe_dir {
return Some(());
}
}
DismissType::Timeout(ref mut timeout) => {
if let Some(_) = timeout.event(ctx, event) {
if timeout.event(ctx, event).is_some() {
return Some(());
}
}

View File

@ -53,7 +53,7 @@ impl VerticalMenu {
pub fn select_word(words: [TString<'static>; 3]) -> Self {
let mut buttons_vec = VerticalMenuButtons::new();
for word in words {
let button = Button::with_text(word.into()).styled(theme::button_default());
let button = Button::with_text(word).styled(theme::button_default());
unwrap!(buttons_vec.push(button));
}
Self::new(buttons_vec)

View File

@ -20,8 +20,3 @@ pub const fn screen() -> Rect {
Rect::from_top_left_and_size(Point::zero(), SIZE)
}
pub const SCREEN: Rect = screen();
/// Spacing between components (e.g. header and main content) and offsets from
/// the side of the screen. Generally applied everywhere except the top side of
/// the header. [px]
pub const SPACING: i16 = 2;

View File

@ -1,6 +1,5 @@
use crate::{
error,
micropython::qstr::Qstr,
strutil::TString,
translations::TR,
ui::{
@ -65,16 +64,17 @@ use crate::{
ui::layout::obj::LayoutObj,
};
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn new_confirm_reset_create(
n_args: usize,
args: *const Obj,
kwargs: *mut Map,
) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, ConfirmResetCreate::new) }
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, ConfirmResetCreate::new_obj) }
}
impl ConfirmResetCreate {
fn new(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
fn new_obj(_args: &[Obj], _kwargs: &Map) -> Result<Obj, error::Error> {
let title: TString = TR::reset__title_create_wallet.into();
let par_array: [Paragraph<'static>; 3] = [
Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, TR::reset__by_continuing)

View File

@ -56,16 +56,17 @@ use crate::{
ui::layout::obj::LayoutObj,
};
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn new_confirm_reset_recover(
n_args: usize,
args: *const Obj,
kwargs: *mut Map,
) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, ConfirmResetRecover::new) }
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, ConfirmResetRecover::new_obj) }
}
impl ConfirmResetRecover {
fn new(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
fn new_obj(_args: &[Obj], _kwargs: &Map) -> Result<Obj, error::Error> {
let par_array: [Paragraph<'static>; 3] = [
Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, TR::reset__by_continuing)
.with_bottom_padding(17),

View File

@ -126,12 +126,13 @@ use crate::{
ui::layout::obj::LayoutObj,
};
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn new_get_address(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, GetAddress::new) }
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, GetAddress::new_obj) }
}
impl GetAddress {
fn new(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
fn new_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
let title: TString = "Receive address".into(); // TODO: address__title_receive_address w/o uppercase
let description: Option<TString> =
kwargs.get(Qstr::MP_QSTR_description)?.try_into_option()?;

View File

@ -73,12 +73,13 @@ use crate::{
ui::layout::obj::LayoutObj,
};
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn new_prompt_backup(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, PromptBackup::new) }
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, PromptBackup::new_obj) }
}
impl PromptBackup {
fn new(_args: &[Obj], _kwargs: &Map) -> Result<Obj, error::Error> {
fn new_obj(_args: &[Obj], _kwargs: &Map) -> Result<Obj, error::Error> {
let title: TString = TR::backup__title_backup_wallet.into();
let par_array: [Paragraph<'static>; 1] = [Paragraph::new(
&theme::TEXT_MAIN_GREY_LIGHT,

View File

@ -8,10 +8,7 @@ use crate::{
text::paragraphs::{Paragraph, Paragraphs},
ComponentExt,
},
flow::{
base::Decision, flow_store, FlowMsg, FlowState, FlowStore, IgnoreSwipe, SwipeFlow,
SwipePage,
},
flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage},
layout::obj::LayoutObj,
},
};
@ -63,12 +60,13 @@ impl FlowState for ShowShareWords {
}
}
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn new_show_share_words(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, ShowShareWords::new) }
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, ShowShareWords::new_obj) }
}
impl ShowShareWords {
fn new(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
fn new_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let share_words_obj: Obj = kwargs.get(Qstr::MP_QSTR_words)?;
let share_words_vec: Vec<TString, 33> = util::iter_into_vec(share_words_obj)?;

View File

@ -66,15 +66,16 @@ use crate::{
ui::layout::obj::LayoutObj,
};
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn new_warning_hi_prio(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, WarningHiPrio::new) }
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, WarningHiPrio::new_obj) }
}
impl WarningHiPrio {
const EXTRA_PADDING: i16 = 6;
fn new(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
let title: TString = kwargs.get_or(Qstr::MP_QSTR_title, TR::words__warning.try_into()?)?;
fn new_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Error> {
let title: TString = kwargs.get_or(Qstr::MP_QSTR_title, TR::words__warning.into())?;
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?;
let cancel: TString = TR::words__cancel_and_exit.into();

View File

@ -1,5 +1,4 @@
use core::{cmp::Ordering, convert::TryInto};
use heapless::Vec;
use crate::{
error::Error,
@ -17,7 +16,6 @@ use crate::{
image::BlendedImage,
jpeg::{ImageBuffer, Jpeg},
paginated::{PageMsg, Paginate},
placed::GridPlaced,
text::{
op::OpTextLayout,
paragraphs::{
@ -26,7 +24,7 @@ use crate::{
},
TextStyle,
},
Border, Component, Empty, FormattedText, Label, Never, Qr, Timeout,
Border, Component, Empty, FormattedText, Label, Never, Timeout,
},
display::tjpgd::jpeg_info,
geometry,
@ -187,7 +185,6 @@ impl ComponentMsgObj for SelectWordCount {
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
match msg {
SelectWordCountMsg::Selected(n) => n.try_into(),
_ => Err(Error::TypeError),
}
}
}
@ -201,18 +198,14 @@ impl ComponentMsgObj for VerticalMenu {
}
impl ComponentMsgObj for StatusScreen {
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
match msg {
() => Ok(CONFIRMED.as_obj()),
}
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
Ok(CONFIRMED.as_obj())
}
}
impl ComponentMsgObj for PromptScreen {
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
match msg {
() => Ok(CONFIRMED.as_obj()),
}
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
Ok(CONFIRMED.as_obj())
}
}
@ -243,12 +236,6 @@ where
}
}
impl ComponentMsgObj for Jpeg {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
// Clippy/compiler complains about conflicting implementations
// TODO move the common impls to a common module
#[cfg(not(feature = "clippy"))]
@ -261,21 +248,6 @@ where
}
}
impl ComponentMsgObj for FormattedText {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
impl<'a, T> ComponentMsgObj for Checklist<T>
where
T: ParagraphSource<'a>,
{
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
impl<F> ComponentMsgObj for NumberInputDialog<F>
where
F: Fn(u32) -> TString<'static>,
@ -289,15 +261,6 @@ where
}
}
impl<T> ComponentMsgObj for Border<T>
where
T: ComponentMsgObj,
{
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
self.inner().msg_try_into_obj(msg)
}
}
impl ComponentMsgObj for Progress {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
@ -320,15 +283,6 @@ impl ComponentMsgObj for Lockscreen<'_> {
}
}
impl<'a, T> ComponentMsgObj for (GridPlaced<Paragraphs<T>>, GridPlaced<FormattedText>)
where
T: ParagraphSource<'a>,
{
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
// Clippy/compiler complains about conflicting implementations
#[cfg(not(feature = "clippy"))]
impl<T> ComponentMsgObj for (Timeout, T)
@ -340,12 +294,6 @@ where
}
}
impl ComponentMsgObj for Qr {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!();
}
}
impl<T> ComponentMsgObj for SimplePage<T>
where
T: ComponentMsgObj + Paginate,
@ -596,7 +544,7 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: Option<TString> =
kwargs.get(Qstr::MP_QSTR_description)?.try_into_option()?;
let verb: TString = kwargs.get_or(Qstr::MP_QSTR_verb, TR::buttons__confirm.try_into()?)?;
let verb: TString = kwargs.get_or(Qstr::MP_QSTR_verb, TR::buttons__confirm.into())?;
let extra: Option<TString> = kwargs.get(Qstr::MP_QSTR_extra)?.try_into_option()?;
let data: Obj = kwargs.get(Qstr::MP_QSTR_data)?;
let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?;
@ -669,7 +617,7 @@ extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *m
jpeg = ImageBuffer::from_slice(theme::IMAGE_HOMESCREEN);
}
if let None = jpeg_info(jpeg.data()) {
if jpeg_info(jpeg.data()).is_none() {
return Err(value_error!("Invalid image."));
};
@ -871,7 +819,7 @@ fn new_show_modal(
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?;
let description: TString = kwargs.get_or(Qstr::MP_QSTR_description, "".into())?;
let button: TString = kwargs.get_or(Qstr::MP_QSTR_button, TR::buttons__continue.try_into()?)?;
let button: TString = kwargs.get_or(Qstr::MP_QSTR_button, TR::buttons__continue.into())?;
let allow_cancel: bool = kwargs.get_or(Qstr::MP_QSTR_allow_cancel, true)?;
let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?;
@ -965,7 +913,7 @@ extern "C" fn new_confirm_fido(n_args: usize, args: *const Obj, kwargs: *mut Map
let controls = Button::cancel_confirm(
Button::with_icon(theme::ICON_CANCEL),
Button::with_text(TR::buttons__confirm.try_into()?).styled(theme::button_confirm()),
Button::with_text(TR::buttons__confirm.into()).styled(theme::button_confirm()),
true,
);
@ -1031,9 +979,9 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -
extern "C" fn new_show_mismatch(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: TString = TR::addr_mismatch__contact_support_at.try_into()?;
let url: TString = TR::addr_mismatch__support_url.try_into()?;
let button: TString = TR::buttons__quit.try_into()?;
let description: TString = TR::addr_mismatch__contact_support_at.into();
let url: TString = TR::addr_mismatch__support_url.into();
let button: TString = TR::buttons__quit.into();
let icon = BlendedImage::new(
theme::IMAGE_BG_OCTAGON,
@ -1344,9 +1292,9 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
let paragraphs = Paragraphs::new([Paragraph::new(&theme::TEXT_NORMAL, description)]);
let notification: TString = if dry_run {
TR::recovery__title_dry_run.try_into()?
TR::recovery__title_dry_run.into()
} else {
TR::recovery__title.try_into()?
TR::recovery__title.into()
};
let content = SwipeUpScreen::new(paragraphs);

View File

@ -676,10 +676,15 @@ pub const TEXT_CHECKLIST_SELECTED: TextStyle =
pub const TEXT_CHECKLIST_DONE: TextStyle =
TextStyle::new(Font::NORMAL, GREEN_DARK, BG, GREY_LIGHT, GREY_LIGHT);
/// Spacing between components (e.g. header and main content) and offsets from
/// the side of the screen. Generally applied everywhere except the top side of
/// the header. [px]
pub const SPACING: i16 = 2;
pub const CONTENT_BORDER: i16 = 0;
pub const BUTTON_HEIGHT: i16 = 62;
pub const BUTTON_WIDTH: i16 = 78;
pub const BUTTON_SPACING: i16 = 2;
pub const BUTTON_SPACING: i16 = SPACING;
pub const KEYBOARD_SPACING: i16 = BUTTON_SPACING;
pub const CHECKLIST_SPACING: i16 = 10;
pub const RECOVERY_SPACING: i16 = 18;

View File

@ -25,7 +25,7 @@ use crate::{
},
TextStyle,
},
Border, Component, Empty, FormattedText, Label, Never, Qr, Timeout,
Border, Component, Empty, FormattedText, Label, Never, Timeout,
},
geometry,
layout::{
@ -195,12 +195,6 @@ where
}
}
impl ComponentMsgObj for Jpeg {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
// Clippy/compiler complains about conflicting implementations
// TODO move the common impls to a common module
#[cfg(not(feature = "clippy"))]
@ -213,21 +207,6 @@ where
}
}
impl ComponentMsgObj for FormattedText {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
impl<'a, T> ComponentMsgObj for Checklist<T>
where
T: ParagraphSource<'a>,
{
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
}
}
impl<F> ComponentMsgObj for NumberInputDialog<F>
where
F: Fn(u32) -> TString<'static>,
@ -241,15 +220,6 @@ where
}
}
impl<T> ComponentMsgObj for Border<T>
where
T: ComponentMsgObj,
{
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
self.inner().msg_try_into_obj(msg)
}
}
impl ComponentMsgObj for Progress {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!()
@ -292,12 +262,6 @@ where
}
}
impl ComponentMsgObj for Qr {
fn msg_try_into_obj(&self, _msg: Self::Msg) -> Result<Obj, Error> {
unreachable!();
}
}
impl<T> ComponentMsgObj for SimplePage<T>
where
T: ComponentMsgObj + Paginate,

View File

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING
import trezorui2
from trezor import TR, io, loop, ui
from trezor import TR, io, loop, ui, utils
from trezor.enums import ButtonRequestType
from trezor.wire import ActionCancelled
from trezor.wire.context import wait as ctx_wait
@ -942,118 +942,118 @@ async def confirm_summary(
await raise_if_not_confirmed(with_info(total_layout, info_layout, br_type, br_code))
async def confirm_ethereum_tx(
recipient: str,
total_amount: str,
maximum_fee: str,
items: Iterable[tuple[str, str]],
br_type: str = "confirm_ethereum_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
chunkify: bool = False,
) -> None:
total_layout = RustLayout(
trezorui2.confirm_total(
title=TR.words__title_summary,
items=[
(f"{TR.words__amount}:", total_amount),
(TR.send__maximum_fee, maximum_fee),
],
info_button=True,
cancel_arrow=True,
)
)
info_layout = RustLayout(
trezorui2.show_info_with_cancel(
title=TR.confirm_total__title_fee,
items=items,
)
)
if not utils.BITCOIN_ONLY:
while True:
# Allowing going back and forth between recipient and summary/details
await confirm_blob(
br_type,
TR.words__recipient.upper(),
recipient,
verb=TR.buttons__continue,
chunkify=chunkify,
)
try:
total_layout.request_complete_repaint()
await raise_if_not_confirmed(
with_info(total_layout, info_layout, br_type, br_code)
async def confirm_ethereum_tx(
recipient: str,
total_amount: str,
maximum_fee: str,
items: Iterable[tuple[str, str]],
br_type: str = "confirm_ethereum_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
chunkify: bool = False,
) -> None:
total_layout = RustLayout(
trezorui2.confirm_total(
title=TR.words__title_summary,
items=[
(f"{TR.words__amount}:", total_amount),
(TR.send__maximum_fee, maximum_fee),
],
info_button=True,
cancel_arrow=True,
)
)
info_layout = RustLayout(
trezorui2.show_info_with_cancel(
title=TR.confirm_total__title_fee,
items=items,
)
break
except ActionCancelled:
continue
async def confirm_ethereum_staking_tx(
title: str,
intro_question: str,
verb: str,
total_amount: str,
maximum_fee: str,
address: str,
address_title: str,
info_items: Iterable[tuple[str, str]],
chunkify: bool = False,
br_type: str = "confirm_ethereum_staking_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
# intro
await confirm_value(
title,
intro_question,
"",
br_type,
br_code,
verb=verb,
value_text_mono=False,
info_items=(("", address),),
info_title=address_title,
chunkify_info=chunkify,
)
# confirmation
if verb == TR.ethereum__staking_claim:
items = ((TR.send__maximum_fee, maximum_fee),)
else:
items = (
(TR.words__amount + ":", total_amount),
(TR.send__maximum_fee, maximum_fee),
)
await confirm_summary(
items, # items
title=title,
info_title=TR.confirm_total__title_fee,
info_items=info_items,
br_type=br_type,
br_code=br_code,
)
while True:
# Allowing going back and forth between recipient and summary/details
await confirm_blob(
br_type,
TR.words__recipient.upper(),
recipient,
verb=TR.buttons__continue,
chunkify=chunkify,
)
async def confirm_solana_tx(
amount: str,
fee: str,
items: Iterable[tuple[str, str]],
amount_title: str | None = None,
fee_title: str | None = None,
br_type: str = "confirm_solana_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
):
amount_title = (
amount_title if amount_title is not None else f"{TR.words__amount}:"
) # def_arg
fee_title = fee_title or TR.words__fee # def_arg
await confirm_summary(
((amount_title, amount), (fee_title, fee)),
info_items=items,
br_type=br_type,
br_code=br_code,
)
try:
total_layout.request_complete_repaint()
await raise_if_not_confirmed(
with_info(total_layout, info_layout, br_type, br_code)
)
break
except ActionCancelled:
continue
async def confirm_ethereum_staking_tx(
title: str,
intro_question: str,
verb: str,
total_amount: str,
maximum_fee: str,
address: str,
address_title: str,
info_items: Iterable[tuple[str, str]],
chunkify: bool = False,
br_type: str = "confirm_ethereum_staking_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
# intro
await confirm_value(
title,
intro_question,
"",
br_type,
br_code,
verb=verb,
value_text_mono=False,
info_items=(("", address),),
info_title=address_title,
chunkify_info=chunkify,
)
# confirmation
if verb == TR.ethereum__staking_claim:
items = ((TR.send__maximum_fee, maximum_fee),)
else:
items = (
(TR.words__amount + ":", total_amount),
(TR.send__maximum_fee, maximum_fee),
)
await confirm_summary(
items, # items
title=title,
info_title=TR.confirm_total__title_fee,
info_items=info_items,
br_type=br_type,
br_code=br_code,
)
async def confirm_solana_tx(
amount: str,
fee: str,
items: Iterable[tuple[str, str]],
amount_title: str | None = None,
fee_title: str | None = None,
br_type: str = "confirm_solana_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
):
amount_title = (
amount_title if amount_title is not None else f"{TR.words__amount}:"
) # def_arg
fee_title = fee_title or TR.words__fee # def_arg
await confirm_summary(
((amount_title, amount), (fee_title, fee)),
info_items=items,
br_type=br_type,
br_code=br_code,
)
async def confirm_joint_total(spending_amount: str, total_amount: str) -> None:

View File

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING
import trezorui2
from trezor import TR, ui
from trezor import TR, ui, utils
if TYPE_CHECKING:
from typing import Any
@ -60,13 +60,13 @@ def pin_progress(message: str, description: str) -> ProgressLayout:
return progress(message, description=description)
def monero_keyimage_sync_progress() -> ProgressLayout:
return progress("", TR.progress__syncing)
if not utils.BITCOIN_ONLY:
def monero_keyimage_sync_progress() -> ProgressLayout:
return progress("", TR.progress__syncing)
def monero_live_refresh_progress() -> ProgressLayout:
return progress("", TR.progress__refreshing, indeterminate=True)
def monero_live_refresh_progress() -> ProgressLayout:
return progress("", TR.progress__refreshing, indeterminate=True)
def monero_transaction_progress_inner() -> ProgressLayout:
return progress("", TR.progress__signing_transaction)
def monero_transaction_progress_inner() -> ProgressLayout:
return progress("", TR.progress__signing_transaction)