mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-05 16:39:08 +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]:
|
def _split_share_into_pages(share_words: Sequence[str], per_page: int = 4) -> list[str]:
|
||||||
pages: list[str] = []
|
pages: list[str] = []
|
||||||
current = ""
|
current = ""
|
||||||
|
fill = 2
|
||||||
|
|
||||||
for i, word in enumerate(share_words):
|
for i, word in enumerate(share_words):
|
||||||
if i % per_page == 0:
|
if i % per_page == 0:
|
||||||
if i != 0:
|
if i != 0:
|
||||||
pages.append(current)
|
pages.append(current)
|
||||||
current = ""
|
current = ""
|
||||||
|
|
||||||
|
lastnum = i + per_page + 1
|
||||||
|
fill = 1 if lastnum < 10 else 2
|
||||||
else:
|
else:
|
||||||
current += "\n"
|
current += "\n"
|
||||||
current += f"{i + 1}. {word}"
|
current += f"{i + 1:>{fill}}. {word}"
|
||||||
|
|
||||||
if current:
|
if current:
|
||||||
pages.append(current)
|
pages.append(current)
|
||||||
@ -49,21 +53,6 @@ async def show_share_words(
|
|||||||
else:
|
else:
|
||||||
title = f"GROUP {group_index + 1} - SHARE {share_index + 1}"
|
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)
|
pages = _split_share_into_pages(share_words)
|
||||||
|
|
||||||
result = await interact(
|
result = await interact(
|
||||||
|
@ -301,7 +301,7 @@ class LayoutContent(UnstructuredJSONReader):
|
|||||||
words: List[str] = []
|
words: List[str] = []
|
||||||
for line in self.screen_content().split("\n"):
|
for line in self.screen_content().split("\n"):
|
||||||
# Dot after index is optional (present on TT, not on TR)
|
# 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:
|
if match:
|
||||||
words.append(match.group(1))
|
words.append(match.group(1))
|
||||||
return words
|
return words
|
||||||
|
Loading…
Reference in New Issue
Block a user