diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index e666a8450..f8d306fb9 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -149,6 +149,7 @@ static void _librust_qstrs(void) { MP_QSTR_confirm_action; MP_QSTR_confirm_address; MP_QSTR_confirm_backup; + MP_QSTR_confirm_backup_written_down; MP_QSTR_confirm_blob; MP_QSTR_confirm_coinjoin; MP_QSTR_confirm_emphasized; @@ -172,6 +173,7 @@ static void _librust_qstrs(void) { MP_QSTR_confirm_value; MP_QSTR_confirm_with_info; MP_QSTR_count; + MP_QSTR_create_backup_flow; MP_QSTR_data; MP_QSTR_data_hash; MP_QSTR_data_len; @@ -620,6 +622,7 @@ static void _librust_qstrs(void) { MP_QSTR_words__error; MP_QSTR_words__fee; MP_QSTR_words__from; + MP_QSTR_words__important; MP_QSTR_words__keep_it_safe; MP_QSTR_words__know_what_your_doing; MP_QSTR_words__my_trezor; diff --git a/core/embed/rust/src/translations/generated/translated_string.rs b/core/embed/rust/src/translations/generated/translated_string.rs index 36ee94f7f..48172a8eb 100644 --- a/core/embed/rust/src/translations/generated/translated_string.rs +++ b/core/embed/rust/src/translations/generated/translated_string.rs @@ -1240,6 +1240,7 @@ pub enum TranslatedString { instructions__swipe_up = 845, // "Swipe up" instructions__tap_to_confirm = 846, // "Tap to confirm" instructions__hold_to_confirm = 847, // "Hold to confirm" + words__important = 848, // "Important" } impl TranslatedString { @@ -2475,6 +2476,7 @@ impl TranslatedString { Self::instructions__swipe_up => "Swipe up", Self::instructions__tap_to_confirm => "Tap to confirm", Self::instructions__hold_to_confirm => "Hold to confirm", + Self::words__important => "Important", } } @@ -3711,6 +3713,7 @@ impl TranslatedString { Qstr::MP_QSTR_instructions__swipe_up => Some(Self::instructions__swipe_up), Qstr::MP_QSTR_instructions__tap_to_confirm => Some(Self::instructions__tap_to_confirm), Qstr::MP_QSTR_instructions__hold_to_confirm => Some(Self::instructions__hold_to_confirm), + Qstr::MP_QSTR_words__important => Some(Self::words__important), _ => None, } } diff --git a/core/embed/rust/src/ui/model_mercury/flow/mod.rs b/core/embed/rust/src/ui/model_mercury/flow/mod.rs index 6cd147fa8..1bffe2ea1 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/mod.rs @@ -1,5 +1,7 @@ pub mod get_address; pub mod confirm_reset_device; +pub mod create_backup; pub use get_address::GetAddress; pub use confirm_reset_device::ConfirmResetDevice; +pub use create_backup::CreateBackup; diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 76b30e6bf..2378150b1 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -1018,42 +1018,50 @@ extern "C" fn new_confirm_fido(n_args: usize, args: *const Obj, kwargs: *mut Map extern "C" fn new_show_warning(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { - let icon = BlendedImage::new( - theme::IMAGE_BG_OCTAGON, - theme::IMAGE_FG_WARN, - theme::WARN_COLOR, - theme::FG, - theme::BG, - ); - new_show_modal(kwargs, icon, theme::button_reset()) + let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?; + + let content = SwipeUpScreen::new(Paragraphs::new([Paragraph::new( + &theme::TEXT_MAIN_GREY_LIGHT, + value, + )])); + let obj = LayoutObj::new( + Frame::left_aligned(title, content) + .with_warning_button() + .button_styled(theme::button_warning_low()) + .with_footer(TR::instructions__swipe_up.into(), None), + )?; + Ok(obj.into()) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } extern "C" fn new_show_success(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { - let icon = BlendedImage::new( - theme::IMAGE_BG_CIRCLE, - theme::IMAGE_FG_SUCCESS, - theme::SUCCESS_COLOR, - theme::FG, - theme::BG, - ); - new_show_modal(kwargs, icon, theme::button_confirm()) + let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let content = StatusScreen::new_success(); + let obj = LayoutObj::new( + Frame::left_aligned(title, content) + .with_footer(TR::instructions__swipe_up.into(), None), + )?; + Ok(obj.into()) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { - let icon = BlendedImage::new( - theme::IMAGE_BG_CIRCLE, - theme::IMAGE_FG_INFO, - theme::INFO_COLOR, - theme::FG, - theme::BG, - ); - new_show_modal(kwargs, icon, theme::button_info()) + let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; + let content = SwipeUpScreen::new(Paragraphs::new([Paragraph::new( + &theme::TEXT_MAIN_GREY_LIGHT, + description, + )])); + let obj = LayoutObj::new( + Frame::left_aligned(title, content) + .with_footer(TR::instructions__swipe_up.into(), None), + )?; + Ok(obj.into()) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } @@ -1330,7 +1338,7 @@ extern "C" fn new_confirm_backup_written_down( args: *const Obj, kwargs: *mut Map, ) -> Obj { - let block = move |_args: &[Obj], _kwargs: &Map| { + let block = move |_args: &[Obj], kwargs: &Map| { let content = PromptScreen::new_hold_to_confirm(); let frame_with_hold_to_confirm = Frame::left_aligned("I wrote down all words in order.".into(), content) @@ -2044,6 +2052,11 @@ pub static mp_module_trezorui2: Module = obj_module! { /// information, 3) Cancel transaction""" Qstr::MP_QSTR_show_tx_context_menu => obj_fn_kw!(0, new_show_tx_context_menu).as_obj(), + // TODO: This is just POC + /// def create_backup_flow() -> LayoutObj[UiResult] + /// """Start create backup or skip flow.""" + Qstr::MP_QSTR_create_backup_flow => obj_fn_kw!(0, flow::create_backup::new_create_backup).as_obj(), + /// def show_share_words( /// *, /// title: str, @@ -2052,6 +2065,11 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Show mnemonic for backup.""" Qstr::MP_QSTR_show_share_words => obj_fn_kw!(0, new_show_share_words).as_obj(), + // TODO: This is just POC + /// def confirm_backup_written_down() -> LayoutObj[UiResult] + /// """Confirm with the user that backup words are written down.""" + Qstr::MP_QSTR_confirm_backup_written_down => obj_fn_kw!(0, new_confirm_backup_written_down).as_obj(), + /// def request_number( /// *, /// title: str, diff --git a/core/embed/rust/src/ui/model_mercury/theme/mod.rs b/core/embed/rust/src/ui/model_mercury/theme/mod.rs index a1325449c..10e1700b4 100644 --- a/core/embed/rust/src/ui/model_mercury/theme/mod.rs +++ b/core/embed/rust/src/ui/model_mercury/theme/mod.rs @@ -292,6 +292,41 @@ pub const fn button_warning_high() -> ButtonStyleSheet { } } +pub const fn button_warning_low() -> ButtonStyleSheet { + ButtonStyleSheet { + normal: &ButtonStyle { + font: Font::DEMIBOLD, + text_color: GREY_LIGHT, + button_color: BG, + icon_color: GREEN_LIME, + background_color: BG, + border_color: BG, + border_radius: RADIUS, + border_width: 0, + }, + active: &ButtonStyle { + font: Font::DEMIBOLD, + text_color: GREY_LIGHT, + button_color: BG, + icon_color: GREEN_LIME, + background_color: BG, + border_color: FG, + border_radius: RADIUS, + border_width: 0, + }, + disabled: &ButtonStyle { + font: Font::DEMIBOLD, + text_color: GREY_LIGHT, + button_color: BG, + icon_color: GREEN_LIME, + background_color: BG, + border_color: BG, + border_radius: RADIUS, + border_width: 0, + }, + } +} + // TODO: delete pub const fn button_confirm() -> ButtonStyleSheet { ButtonStyleSheet { diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 11aa0c7bd..d03a58cdc 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -395,6 +395,11 @@ def show_tx_context_menu() -> LayoutObj[int]: information, 3) Cancel transaction""" +# rust/src/ui/model_mercury/layout.rs +def create_backup_flow() -> LayoutObj[UiResult] +"""Start create backup or skip flow.""" + + # rust/src/ui/model_mercury/layout.rs def show_share_words( *, @@ -404,6 +409,11 @@ def show_share_words( """Show mnemonic for backup.""" +# rust/src/ui/model_mercury/layout.rs +def confirm_backup_written_down() -> LayoutObj[UiResult] +"""Confirm with the user that backup words are written down.""" + + # rust/src/ui/model_mercury/layout.rs def request_number( *, diff --git a/core/mocks/trezortranslate_keys.pyi b/core/mocks/trezortranslate_keys.pyi index d900bde92..0385ce3fc 100644 --- a/core/mocks/trezortranslate_keys.pyi +++ b/core/mocks/trezortranslate_keys.pyi @@ -826,6 +826,7 @@ class TR: words__error: str = "Error" words__fee: str = "Fee" words__from: str = "from" + words__important: str = "Important" words__keep_it_safe: str = "Keep it safe!" words__know_what_your_doing: str = "Continue only if you know what you are doing!" words__my_trezor: str = "My Trezor" diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index f946047b4..af012cfef 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -340,37 +340,21 @@ async def confirm_reset_device(title: str, recovery: bool = False) -> None: ) -# TODO cleanup @ redesign async def prompt_backup() -> bool: - result = await interact( - RustLayout( - trezorui2.confirm_action( - title=TR.words__title_success, - action=TR.backup__new_wallet_successfully_created, - description=TR.backup__it_should_be_backed_up, - verb=TR.buttons__back_up, - verb_cancel=TR.buttons__skip, - ) - ), + # result = await interact(RustLayout(trezorui2.)) + await interact( + RustLayout(trezorui2.show_success(title=TR.backup__new_wallet_created)), "backup_device", ButtonRequestType.ResetDevice, ) - if result is CONFIRMED: - return True result = await interact( - RustLayout( - trezorui2.confirm_action( - title=TR.words__warning.upper(), - action=TR.backup__want_to_skip, - description=TR.backup__can_back_up_anytime, - verb=TR.buttons__back_up, - verb_cancel=TR.buttons__skip, - ) - ), + # TODO: this is just POC + RustLayout(trezorui2.create_backup_flow()), "backup_device", ButtonRequestType.ResetDevice, ) + return result is CONFIRMED @@ -586,8 +570,8 @@ async def show_success( interact( RustLayout( trezorui2.show_success( - title=content, - description=subheader or "", + title=subheader or "", + description="", button=button.upper(), allow_cancel=False, ) diff --git a/core/src/trezor/ui/layouts/mercury/reset.py b/core/src/trezor/ui/layouts/mercury/reset.py index c0d9dd46e..337ab74d4 100644 --- a/core/src/trezor/ui/layouts/mercury/reset.py +++ b/core/src/trezor/ui/layouts/mercury/reset.py @@ -32,9 +32,16 @@ async def show_share_words( group_index + 1, share_index + 1 ) + await RustLayout( + trezorui2.show_share_words( + title=title, + pages=share_words, + ), + ) + result = await interact( RustLayout( - trezorui2.show_share_words( + trezorui2.confirm_backup_written_down( title=title, pages=share_words, ), @@ -42,6 +49,13 @@ async def show_share_words( "backup_words", ButtonRequestType.ResetDevice, ) + + result = await RustLayout( + trezorui2.show_info( + title="Check wallet backup", + description="Let's do a quick check of your backup.", + ) + ) if result != CONFIRMED: raise ActionCancelled @@ -296,15 +310,22 @@ async def slip39_advanced_prompt_group_threshold(num_of_groups: int) -> int: async def show_warning_backup(slip39: bool) -> None: result = await interact( RustLayout( - trezorui2.show_info( - title=TR.reset__never_make_digital_copy, - button=TR.buttons__ok_i_understand, + trezorui2.show_warning( + title=TR.words__important, + value=TR.reset__never_make_digital_copy, + button="", allow_cancel=False, ) ), "backup_warning", ButtonRequestType.ResetDevice, ) + result = await RustLayout( + trezorui2.show_info( + title="Wallet backup", + description="Write the following words in order on your wallet backup card.", + ) + ) if result != CONFIRMED: raise ActionCancelled @@ -332,8 +353,9 @@ async def show_reset_warning( RustLayout( trezorui2.show_warning( title=subheader or "", - description=content, - button=button.upper(), + description="", + value=content, + button="", allow_cancel=False, ) ), diff --git a/core/translations/en.json b/core/translations/en.json index dd7c81da5..2f1f2ab27 100644 --- a/core/translations/en.json +++ b/core/translations/en.json @@ -828,6 +828,7 @@ "words__error": "Error", "words__fee": "Fee", "words__from": "from", + "words__important": "Important", "words__keep_it_safe": "Keep it safe!", "words__know_what_your_doing": "Continue only if you know what you are doing!", "words__my_trezor": "My Trezor", diff --git a/core/translations/order.json b/core/translations/order.json index 7142fdc0f..bc79d801e 100644 --- a/core/translations/order.json +++ b/core/translations/order.json @@ -847,4 +847,5 @@ "845": "instructions__swipe_up", "846": "instructions__tap_to_confirm", "847": "instructions__hold_to_confirm", + "848": "words__important" } diff --git a/core/translations/signatures.json b/core/translations/signatures.json index 5a6bb8c2a..d0d33009c 100644 --- a/core/translations/signatures.json +++ b/core/translations/signatures.json @@ -1,8 +1,8 @@ { "current": { - "merkle_root": "5a83288c2b984cb98dfed78216ab2b24a9f01bc6d49b1e9484d7140241d7be0c", - "datetime": "2024-04-18T10:27:35.547426", - "commit": "c09789f9dd2390b79e25be884e96ede021ab8151" + "merkle_root": "4a9791a69489039202914aee7c3ee810e205d13cfa4fa3e072420f380f577d0f", + "datetime": "2024-04-21T12:56:00.193900", + "commit": "224f031725c91f1a06715a038555916374a61706" }, "history": [ {