-
-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/ui): unify progress.py code between models, implement stora…
…ge translations fixes #3520
- Loading branch information
Showing
18 changed files
with
190 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Translate also texts for PIN progress loaders. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
core/embed/rust/src/translations/generated/translated_string.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,100 @@ | ||
from trezor import utils | ||
from typing import TYPE_CHECKING | ||
|
||
if utils.UI_LAYOUT == "TT": | ||
from .tt.progress import * # noqa: F401,F403 | ||
elif utils.UI_LAYOUT == "TR": | ||
from .tr.progress import * # noqa: F401,F403 | ||
import trezorui2 | ||
from trezor import TR, config, ui, utils | ||
|
||
if TYPE_CHECKING: | ||
from typing import Any | ||
|
||
from .common import ProgressLayout | ||
|
||
|
||
def _storage_message_to_str(message: config.StorageMessage | None) -> str | None: | ||
from trezor import TR | ||
|
||
if message is None: | ||
return None | ||
|
||
if message == config.StorageMessage.NO_MSG: | ||
return "" | ||
if message == config.StorageMessage.VERIFYING_PIN_MSG: | ||
return TR.storage_msg__verifying_pin | ||
if message == config.StorageMessage.PROCESSING_MSG: | ||
return TR.storage_msg__processing | ||
if message == config.StorageMessage.STARTING_MSG: | ||
return TR.storage_msg__starting | ||
if message == config.StorageMessage.WRONG_PIN_MSG: | ||
return TR.storage_msg__wrong_pin | ||
raise RuntimeError # unknown message | ||
|
||
|
||
class RustProgress: | ||
def __init__( | ||
self, | ||
layout: Any, | ||
): | ||
self.layout = layout | ||
ui.backlight_fade(ui.style.BACKLIGHT_DIM) | ||
self.layout.attach_timer_fn(self.set_timer) | ||
self.layout.paint() | ||
ui.refresh() | ||
ui.backlight_fade(ui.style.BACKLIGHT_NORMAL) | ||
|
||
def set_timer(self, token: int, deadline: int) -> None: | ||
raise RuntimeError # progress layouts should not set timers | ||
|
||
def report(self, value: int, description: str | None = None): | ||
msg = self.layout.progress_event(value, description or "") | ||
assert msg is None | ||
self.layout.paint() | ||
ui.refresh() | ||
|
||
|
||
def progress( | ||
description: str | None = None, | ||
title: str | None = None, | ||
indeterminate: bool = False, | ||
) -> ProgressLayout: | ||
if description is None: | ||
description = TR.progress__please_wait # def_arg | ||
|
||
if title is not None: | ||
title = title.upper() | ||
elif not utils.MODEL_IS_T2B1: | ||
# on TT, uppercase the description which ends up on top of the screen | ||
# when no title is set | ||
description = description.upper() | ||
|
||
return RustProgress( | ||
layout=trezorui2.show_progress( | ||
description=description, | ||
title=title, | ||
indeterminate=indeterminate, | ||
) | ||
) | ||
|
||
|
||
def bitcoin_progress(message: str) -> ProgressLayout: | ||
return progress(message) | ||
|
||
|
||
def coinjoin_progress(message: str) -> ProgressLayout: | ||
return RustProgress( | ||
layout=trezorui2.show_progress_coinjoin(title=message, indeterminate=False) | ||
) | ||
|
||
|
||
def pin_progress(title: config.StorageMessage, description: str) -> ProgressLayout: | ||
return progress(description=description, title=_storage_message_to_str(title)) | ||
|
||
|
||
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_transaction_progress_inner() -> ProgressLayout: | ||
return progress(TR.progress__signing_transaction) |
Oops, something went wrong.