mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-19 04:48:12 +00:00
fix(core/ui): T3T1: get rid of some of the remaining button dialogs
This commit is contained in:
parent
69e406f7cf
commit
662f13136f
@ -1,9 +1,12 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
error,
|
error,
|
||||||
|
maybe_trace::MaybeTrace,
|
||||||
strutil::TString,
|
strutil::TString,
|
||||||
translations::TR,
|
translations::TR,
|
||||||
ui::{
|
ui::{
|
||||||
component::{text::paragraphs::Paragraph, ComponentExt, SwipeDirection},
|
component::{
|
||||||
|
text::paragraphs::Paragraph, Component, ComponentExt, Paginate, SwipeDirection,
|
||||||
|
},
|
||||||
flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage},
|
flow::{base::Decision, flow_store, FlowMsg, FlowState, FlowStore, SwipeFlow, SwipePage},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -208,3 +211,41 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
|
|||||||
Ok(LayoutObj::new(res)?.into())
|
Ok(LayoutObj::new(res)?.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_confirm_action_simple<T: Component + Paginate + Clone + MaybeTrace + 'static>(
|
||||||
|
content: T,
|
||||||
|
title: TString<'static>,
|
||||||
|
subtitle: Option<TString<'static>>,
|
||||||
|
verb: Option<TString<'static>>,
|
||||||
|
verb_cancel: Option<TString<'static>>,
|
||||||
|
) -> Result<Obj, error::Error> {
|
||||||
|
let mut frame = Frame::left_aligned(title, SwipePage::vertical(content))
|
||||||
|
.with_menu_button()
|
||||||
|
.with_footer(TR::instructions__swipe_up.into(), verb);
|
||||||
|
if let Some(subtitle) = subtitle {
|
||||||
|
frame = frame.with_subtitle(subtitle)
|
||||||
|
}
|
||||||
|
let content_intro =
|
||||||
|
frame.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
|
||||||
|
|
||||||
|
let content_menu = if let Some(verb_cancel) = verb_cancel {
|
||||||
|
Frame::left_aligned(
|
||||||
|
"".into(),
|
||||||
|
VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Frame::left_aligned(
|
||||||
|
"".into(),
|
||||||
|
VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::buttons__cancel.into()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.with_cancel_button()
|
||||||
|
.map(move |msg| match msg {
|
||||||
|
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
|
||||||
|
FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
|
||||||
|
});
|
||||||
|
|
||||||
|
let store = flow_store().add(content_intro)?.add(content_menu)?;
|
||||||
|
let res = SwipeFlow::new(ConfirmActionSimple::Intro, store)?;
|
||||||
|
Ok(LayoutObj::new(res)?.into())
|
||||||
|
}
|
||||||
|
@ -10,7 +10,7 @@ pub mod request_number;
|
|||||||
pub mod show_share_words;
|
pub mod show_share_words;
|
||||||
pub mod warning_hi_prio;
|
pub mod warning_hi_prio;
|
||||||
|
|
||||||
pub use confirm_action::new_confirm_action;
|
pub use confirm_action::{new_confirm_action, new_confirm_action_simple};
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use confirm_output::new_confirm_output;
|
pub use confirm_output::new_confirm_output;
|
||||||
|
@ -449,6 +449,33 @@ impl ConfirmBlobParams {
|
|||||||
let obj = LayoutObj::new(frame)?;
|
let obj = LayoutObj::new(frame)?;
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn into_flow(self) -> Result<Obj, Error> {
|
||||||
|
let paragraphs = ConfirmBlob {
|
||||||
|
description: self.description.unwrap_or("".into()),
|
||||||
|
extra: self.extra.unwrap_or("".into()),
|
||||||
|
data: self.data.try_into()?,
|
||||||
|
description_font: &theme::TEXT_NORMAL,
|
||||||
|
extra_font: &theme::TEXT_DEMIBOLD,
|
||||||
|
data_font: if self.chunkify {
|
||||||
|
let data: TString = self.data.try_into()?;
|
||||||
|
theme::get_chunkified_text_style(data.len())
|
||||||
|
} else if self.text_mono {
|
||||||
|
&theme::TEXT_MONO
|
||||||
|
} else {
|
||||||
|
&theme::TEXT_NORMAL
|
||||||
|
},
|
||||||
|
}
|
||||||
|
.into_paragraphs();
|
||||||
|
|
||||||
|
flow::new_confirm_action_simple(
|
||||||
|
paragraphs,
|
||||||
|
self.title,
|
||||||
|
self.subtitle,
|
||||||
|
self.verb,
|
||||||
|
self.verb_cancel,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||||
@ -472,7 +499,7 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map
|
|||||||
ConfirmBlobParams::new(title, data, description, verb, verb_cancel, hold)
|
ConfirmBlobParams::new(title, data, description, verb, verb_cancel, hold)
|
||||||
.with_extra(extra)
|
.with_extra(extra)
|
||||||
.with_chunkify(chunkify)
|
.with_chunkify(chunkify)
|
||||||
.into_layout()
|
.into_flow()
|
||||||
};
|
};
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
}
|
}
|
||||||
@ -638,7 +665,7 @@ extern "C" fn new_confirm_value(n_args: usize, args: *const Obj, kwargs: *mut Ma
|
|||||||
.with_info_button(info_button)
|
.with_info_button(info_button)
|
||||||
.with_chunkify(chunkify)
|
.with_chunkify(chunkify)
|
||||||
.with_text_mono(text_mono)
|
.with_text_mono(text_mono)
|
||||||
.into_layout()
|
.into_flow()
|
||||||
};
|
};
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
}
|
}
|
||||||
@ -693,10 +720,10 @@ extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs:
|
|||||||
Paragraph::new(&theme::TEXT_MONO, amount_new),
|
Paragraph::new(&theme::TEXT_MONO, amount_new),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let obj = LayoutObj::new(Frame::left_aligned(
|
let obj = LayoutObj::new(SwipeUpScreen::new(
|
||||||
TR::modify_amount__title.into(),
|
Frame::left_aligned(TR::modify_amount__title.into(), paragraphs)
|
||||||
ButtonPage::new(paragraphs, theme::BG)
|
.with_cancel_button()
|
||||||
.with_cancel_confirm(Some("^".into()), Some(TR::buttons__continue.into())),
|
.with_footer(TR::instructions__swipe_up.into(), None),
|
||||||
))?;
|
))?;
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
};
|
};
|
||||||
@ -735,15 +762,11 @@ extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *m
|
|||||||
Paragraph::new(&theme::TEXT_MONO, total_fee_new),
|
Paragraph::new(&theme::TEXT_MONO, total_fee_new),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let obj = LayoutObj::new(
|
let obj = LayoutObj::new(SwipeUpScreen::new(
|
||||||
Frame::left_aligned(
|
Frame::left_aligned(title, paragraphs)
|
||||||
title,
|
.with_menu_button()
|
||||||
ButtonPage::new(paragraphs, theme::BG)
|
.with_footer(TR::instructions__swipe_up.into(), None),
|
||||||
.with_hold()?
|
))?;
|
||||||
.with_swipe_left(),
|
|
||||||
)
|
|
||||||
.with_menu_button(),
|
|
||||||
)?;
|
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
};
|
};
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
@ -1031,11 +1054,10 @@ extern "C" fn new_confirm_with_info(n_args: usize, args: *const Obj, kwargs: *mu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let buttons = Button::cancel_info_confirm(button, info_button);
|
let obj = LayoutObj::new(SwipeUpScreen::new(
|
||||||
|
Frame::left_aligned(title, paragraphs.into_paragraphs())
|
||||||
let obj = LayoutObj::new(Frame::left_aligned(
|
.with_menu_button()
|
||||||
title,
|
.with_footer(TR::instructions__swipe_up.into(), Some(button)),
|
||||||
Dialog::new(paragraphs.into_paragraphs(), buttons),
|
|
||||||
))?;
|
))?;
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
};
|
};
|
||||||
|
@ -1613,6 +1613,7 @@ def test_information_cancel(client: Client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip_t3t1(reason="Not yet implemented in new UI")
|
||||||
@pytest.mark.skip_t1b1(reason="Cannot test layouts on T1")
|
@pytest.mark.skip_t1b1(reason="Cannot test layouts on T1")
|
||||||
def test_information_replacement(client: Client):
|
def test_information_replacement(client: Client):
|
||||||
# Use the change output and an external output to bump the fee.
|
# Use the change output and an external output to bump the fee.
|
||||||
|
@ -62,6 +62,7 @@ def test_cardano_sign_tx(client: Client, parameters, result):
|
|||||||
assert response == _transform_expected_result(result)
|
assert response == _transform_expected_result(result)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip_t3t1(reason="Not yet implemented in new UI")
|
||||||
@parametrize_using_common_fixtures("cardano/sign_tx.show_details.json")
|
@parametrize_using_common_fixtures("cardano/sign_tx.show_details.json")
|
||||||
def test_cardano_sign_tx_show_details(client: Client, parameters, result):
|
def test_cardano_sign_tx_show_details(client: Client, parameters, result):
|
||||||
response = call_sign_tx(client, parameters, show_details_input_flow, chunkify=True)
|
response = call_sign_tx(client, parameters, show_details_input_flow, chunkify=True)
|
||||||
|
@ -97,6 +97,7 @@ DATA = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip_t3t1(reason="Not yet implemented in new UI")
|
||||||
@pytest.mark.skip_t1b1
|
@pytest.mark.skip_t1b1
|
||||||
def test_ethereum_sign_typed_data_show_more_button(client: Client):
|
def test_ethereum_sign_typed_data_show_more_button(client: Client):
|
||||||
with client:
|
with client:
|
||||||
|
@ -457,6 +457,7 @@ def test_signtx_data_pagination(client: Client, flow):
|
|||||||
_sign_tx_call()
|
_sign_tx_call()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip_t3t1(reason="Not yet implemented in new UI")
|
||||||
@pytest.mark.skip_t1b1("T1 does not support Everstake")
|
@pytest.mark.skip_t1b1("T1 does not support Everstake")
|
||||||
@parametrize_using_common_fixtures("ethereum/sign_tx_staking.json")
|
@parametrize_using_common_fixtures("ethereum/sign_tx_staking.json")
|
||||||
@pytest.mark.parametrize("chunkify", (True, False))
|
@pytest.mark.parametrize("chunkify", (True, False))
|
||||||
|
@ -264,12 +264,12 @@ class InputFlowSignMessagePagination(InputFlowBase):
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
br = yield
|
br = yield
|
||||||
assert br.pages is not None
|
# assert br.pages is not None
|
||||||
for i in range(br.pages):
|
for i in range(br.pages or 1):
|
||||||
layout = self.debug.wait_layout()
|
layout = self.debug.wait_layout()
|
||||||
layouts.append(layout)
|
layouts.append(layout)
|
||||||
|
|
||||||
if i < br.pages - 1:
|
if br.pages and i < br.pages - 1:
|
||||||
self.debug.swipe_up()
|
self.debug.swipe_up()
|
||||||
|
|
||||||
self.message_read = multipage_content(layouts)
|
self.message_read = multipage_content(layouts)
|
||||||
|
Loading…
Reference in New Issue
Block a user