mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-17 11:58:13 +00:00
fix(core/ui): padding when backing up mnemonic words
[no changelog]
This commit is contained in:
parent
703a38517a
commit
46f9e898ca
@ -20,15 +20,19 @@ CONFIRMED = trezorui2.CONFIRMED # global_import_cache
|
||||
def _split_share_into_pages(share_words: Sequence[str], per_page: int = 4) -> list[str]:
|
||||
pages: list[str] = []
|
||||
current = ""
|
||||
fill = 2
|
||||
|
||||
for i, word in enumerate(share_words):
|
||||
if i % per_page == 0:
|
||||
if i != 0:
|
||||
pages.append(current)
|
||||
current = ""
|
||||
|
||||
lastnum = i + per_page + 1
|
||||
fill = 1 if lastnum < 10 else 2
|
||||
else:
|
||||
current += "\n"
|
||||
current += f"{i + 1}. {word}"
|
||||
current += f"{i + 1:>{fill}}. {word}"
|
||||
|
||||
if current:
|
||||
pages.append(current)
|
||||
@ -49,21 +53,6 @@ async def show_share_words(
|
||||
else:
|
||||
title = f"GROUP {group_index + 1} - SHARE {share_index + 1}"
|
||||
|
||||
# result = await interact(
|
||||
# ctx,
|
||||
# RustLayout(
|
||||
# trezorui2.show_simple(
|
||||
# title=title,
|
||||
# description=f"Write down these {len(share_words)} words in the exact order:",
|
||||
# button="SHOW WORDS",
|
||||
# ),
|
||||
# ),
|
||||
# "confirm_backup_words",
|
||||
# ButtonRequestType.ResetDevice,
|
||||
# )
|
||||
# if result != CONFIRMED:
|
||||
# raise ActionCancelled
|
||||
|
||||
pages = _split_share_into_pages(share_words)
|
||||
|
||||
result = await interact(
|
||||
|
@ -301,7 +301,7 @@ class LayoutContent(UnstructuredJSONReader):
|
||||
words: List[str] = []
|
||||
for line in self.screen_content().split("\n"):
|
||||
# Dot after index is optional (present on TT, not on TR)
|
||||
match = re.match(r"^\d+\.? (\w+)$", line)
|
||||
match = re.match(r"^\s*\d+\.? (\w+)$", line)
|
||||
if match:
|
||||
words.append(match.group(1))
|
||||
return words
|
||||
|
Loading…
Reference in New Issue
Block a user