mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-09 11:55:58 +00:00
feat(eckhart): implement confirm_set_new_pin
- add1: make `show_success` not render empty action bar button - add2: top aligned confirm action
This commit is contained in:
parent
8f2ee16557
commit
7353e5f135
@ -0,0 +1,93 @@
|
||||
use crate::{
|
||||
error,
|
||||
strutil::TString,
|
||||
translations::TR,
|
||||
ui::{
|
||||
component::{
|
||||
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, Paragraphs},
|
||||
ComponentExt as _,
|
||||
},
|
||||
flow::{
|
||||
base::{Decision, DecisionBuilder as _},
|
||||
FlowController, FlowMsg, SwipeFlow,
|
||||
},
|
||||
geometry::{Direction, LinearPlacement},
|
||||
layout_eckhart::firmware::TextScreenMsg,
|
||||
},
|
||||
};
|
||||
|
||||
use super::super::{
|
||||
component::Button,
|
||||
firmware::{ActionBar, Header, TextScreen},
|
||||
theme,
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub enum SetNewPin {
|
||||
Intro,
|
||||
CancelPin,
|
||||
}
|
||||
|
||||
impl FlowController for SetNewPin {
|
||||
#[inline]
|
||||
fn index(&'static self) -> usize {
|
||||
*self as usize
|
||||
}
|
||||
|
||||
fn handle_swipe(&'static self, _direction: Direction) -> Decision {
|
||||
self.do_nothing()
|
||||
}
|
||||
|
||||
fn handle_event(&'static self, msg: FlowMsg) -> Decision {
|
||||
match (self, msg) {
|
||||
(Self::Intro, FlowMsg::Cancelled) => Self::CancelPin.goto(),
|
||||
(Self::Intro, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed),
|
||||
(Self::CancelPin, FlowMsg::Cancelled) => Self::Intro.goto(),
|
||||
(Self::CancelPin, FlowMsg::Confirmed) => self.return_msg(FlowMsg::Confirmed),
|
||||
_ => self.do_nothing(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_set_new_pin(
|
||||
title: TString<'static>,
|
||||
description: TString<'static>,
|
||||
) -> Result<SwipeFlow, error::Error> {
|
||||
let paragraphs = Paragraphs::new(Paragraph::new(&theme::firmware::TEXT_REGULAR, description))
|
||||
.with_placement(LinearPlacement::vertical());
|
||||
let content_intro = TextScreen::new(paragraphs)
|
||||
.with_header(Header::new(title))
|
||||
.with_action_bar(ActionBar::new_cancel_confirm())
|
||||
.map(|msg| match msg {
|
||||
TextScreenMsg::Cancelled => Some(FlowMsg::Cancelled),
|
||||
TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
let paragraphs_cancel_intro = ParagraphVecShort::from_iter([
|
||||
Paragraph::new(
|
||||
&theme::firmware::TEXT_REGULAR_WARNING,
|
||||
TR::words__not_recommended,
|
||||
),
|
||||
Paragraph::new(&theme::firmware::TEXT_REGULAR, TR::pin__cancel_info),
|
||||
])
|
||||
.into_paragraphs()
|
||||
.with_placement(LinearPlacement::vertical());
|
||||
|
||||
let content_cancel_pin = TextScreen::new(paragraphs_cancel_intro)
|
||||
.with_header(Header::new(title))
|
||||
.with_action_bar(ActionBar::new_double(
|
||||
Button::with_icon(theme::ICON_CHEVRON_LEFT),
|
||||
Button::with_text(TR::buttons__continue.into()),
|
||||
))
|
||||
.map(|msg| match msg {
|
||||
TextScreenMsg::Cancelled => Some(FlowMsg::Cancelled),
|
||||
TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
let mut res = SwipeFlow::new(&SetNewPin::Intro)?;
|
||||
res.add_page(&SetNewPin::Intro, content_intro)?
|
||||
.add_page(&SetNewPin::CancelPin, content_cancel_pin)?;
|
||||
Ok(res)
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
pub mod confirm_reset;
|
||||
pub mod confirm_set_new_pin;
|
||||
pub mod get_address;
|
||||
pub mod prompt_backup;
|
||||
pub mod request_passphrase;
|
||||
@ -6,6 +7,7 @@ pub mod show_danger;
|
||||
pub mod show_share_words;
|
||||
|
||||
pub use confirm_reset::new_confirm_reset;
|
||||
pub use confirm_set_new_pin::new_set_new_pin;
|
||||
pub use get_address::GetAddress;
|
||||
pub use prompt_backup::PromptBackup;
|
||||
pub use request_passphrase::RequestPassphrase;
|
||||
|
@ -73,6 +73,9 @@ pub const TEXT_MONO_LIGHT: TextStyle = TextStyle::new(
|
||||
GREY_LIGHT,
|
||||
);
|
||||
|
||||
pub const TEXT_REGULAR_WARNING: TextStyle =
|
||||
TextStyle::new(fonts::FONT_SATOSHI_REGULAR_38, RED, BG, GREY, GREY);
|
||||
|
||||
pub const TEXT_MEDIUM_EXTRA_LIGHT: TextStyle = TextStyle::new(
|
||||
fonts::FONT_SATOSHI_MEDIUM_26,
|
||||
GREY_EXTRA_LIGHT,
|
||||
|
@ -72,7 +72,7 @@ impl FirmwareUI for UIEckhart {
|
||||
.color(theme::GREY_LIGHT)
|
||||
.text(action, fonts::FONT_SATOSHI_REGULAR_38);
|
||||
};
|
||||
FormattedText::new(ops).vertically_centered()
|
||||
FormattedText::new(ops)
|
||||
};
|
||||
|
||||
let verb = verb.unwrap_or(TR::buttons__confirm.into());
|
||||
@ -359,10 +359,11 @@ impl FirmwareUI for UIEckhart {
|
||||
}
|
||||
|
||||
fn flow_confirm_set_new_pin(
|
||||
_title: TString<'static>,
|
||||
_description: TString<'static>,
|
||||
title: TString<'static>,
|
||||
description: TString<'static>,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(c"not implemented"))
|
||||
let flow = flow::confirm_set_new_pin::new_set_new_pin(title, description)?;
|
||||
Ok(flow)
|
||||
}
|
||||
|
||||
fn flow_get_address(
|
||||
|
@ -1353,7 +1353,7 @@ async def request_pin_on_device(
|
||||
|
||||
|
||||
async def confirm_reenter_pin(is_wipe_code: bool = False) -> None:
|
||||
"""Not supported for TT."""
|
||||
"""Not supported for Bolt."""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -365,11 +365,13 @@ def show_success(
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
) -> Awaitable[None]:
|
||||
button = button or TR.buttons__continue # def_arg
|
||||
return raise_if_not_confirmed(
|
||||
trezorui_api.show_success(
|
||||
title=subheader if subheader else "",
|
||||
button=button if button else "",
|
||||
button=button,
|
||||
description=content,
|
||||
allow_cancel=False,
|
||||
),
|
||||
br_name,
|
||||
ButtonRequestType.Success,
|
||||
@ -1000,9 +1002,8 @@ def request_pin_on_device(
|
||||
|
||||
|
||||
async def confirm_reenter_pin(is_wipe_code: bool = False) -> None:
|
||||
# FIXME: not implemented
|
||||
# not supported on mercury either?
|
||||
raise NotImplementedError
|
||||
"""Not supported for Eckhart."""
|
||||
pass
|
||||
|
||||
|
||||
def pin_mismatch_popup(is_wipe_code: bool = False) -> Awaitable[ui.UiResult]:
|
||||
|
@ -99,7 +99,7 @@ async def show_group_share_success(share_index: int, group_index: int) -> None:
|
||||
|
||||
|
||||
async def continue_recovery(
|
||||
_button_label: str, # unused on mercury
|
||||
_button_label: str, # unused on delizia
|
||||
text: str,
|
||||
subtext: str | None,
|
||||
recovery_type: RecoveryType,
|
||||
|
Loading…
Reference in New Issue
Block a user