mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
trezor.ui: prototype of seed setup
This commit is contained in:
parent
36666de503
commit
d47e9fb855
@ -1,5 +1,6 @@
|
|||||||
from micropython import const
|
from micropython import const
|
||||||
from trezor import wire, ui
|
from trezor import wire, ui
|
||||||
|
from trezor.ui.container import Container
|
||||||
from trezor.utils import unimport, chunks
|
from trezor.utils import unimport, chunks
|
||||||
import ubinascii
|
import ubinascii
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ async def layout_reset_device(session_id, msg):
|
|||||||
|
|
||||||
|
|
||||||
async def show_mnemonic_by_word(session_id, mnemonic):
|
async def show_mnemonic_by_word(session_id, mnemonic):
|
||||||
from trezor.ui.text import Text
|
from trezor.ui.text import Text, RecoveryWordText
|
||||||
from trezor.messages.ButtonRequestType import ConfirmWord
|
from trezor.messages.ButtonRequestType import ConfirmWord
|
||||||
from apps.common.confirm import confirm
|
from apps.common.confirm import confirm
|
||||||
|
|
||||||
@ -75,16 +76,20 @@ async def show_mnemonic_by_word(session_id, mnemonic):
|
|||||||
|
|
||||||
for index, word in enumerate(words):
|
for index, word in enumerate(words):
|
||||||
current_word = word
|
current_word = word
|
||||||
|
content = Container(
|
||||||
|
Text('Recovery seed setup', ui.ICON_RESET, 'Write down seed word'),
|
||||||
|
RecoveryWordText(index + 1, word))
|
||||||
await confirm(session_id,
|
await confirm(session_id,
|
||||||
Text('Write down seed', ui.ICON_RESET,
|
content,
|
||||||
'%d. %s' % (index, word)),
|
|
||||||
ConfirmWord)
|
ConfirmWord)
|
||||||
|
|
||||||
for index, word in enumerate(words):
|
for index, word in enumerate(words):
|
||||||
current_word = word
|
current_word = word
|
||||||
|
content = Container(
|
||||||
|
Text('Recovery seed setup', ui.ICON_RESET, 'Confirm seed word'),
|
||||||
|
RecoveryWordText(index + 1, word))
|
||||||
await confirm(session_id,
|
await confirm(session_id,
|
||||||
Text('Confirm seed', ui.ICON_RESET,
|
content,
|
||||||
'%d. %s' % (index, word)),
|
|
||||||
ConfirmWord)
|
ConfirmWord)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
from micropython import const
|
from micropython import const
|
||||||
from trezor import ui
|
from trezor import ui
|
||||||
from trezor.ui import Widget
|
|
||||||
|
|
||||||
TEXT_HEADER_HEIGHT = const(32)
|
TEXT_HEADER_HEIGHT = const(32)
|
||||||
TEXT_LINE_HEIGHT = const(23)
|
TEXT_LINE_HEIGHT = const(23)
|
||||||
TEXT_MARGIN_LEFT = const(10)
|
TEXT_MARGIN_LEFT = const(10)
|
||||||
|
|
||||||
|
|
||||||
class Text(Widget):
|
class Text(ui.Widget):
|
||||||
|
|
||||||
def __init__(self, header_text, header_icon, *content):
|
def __init__(self, header_text, header_icon, *content):
|
||||||
self.header_text = header_text
|
self.header_text = header_text
|
||||||
@ -33,3 +32,25 @@ class Text(Widget):
|
|||||||
|
|
||||||
def send(self, event, pos):
|
def send(self, event, pos):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RecoveryWordText(ui.Widget):
|
||||||
|
|
||||||
|
def __init__(self, number, word):
|
||||||
|
self.number = ('%d.' % number)
|
||||||
|
self.word = word
|
||||||
|
|
||||||
|
def render(self):
|
||||||
|
offset_y = 96
|
||||||
|
style = ui.BOLD
|
||||||
|
fg = ui.WHITE
|
||||||
|
bg = ui.BLACKISH
|
||||||
|
ui.display.bar(0, offset_y - TEXT_LINE_HEIGHT, 240, TEXT_LINE_HEIGHT + 10, bg)
|
||||||
|
ui.display.text(TEXT_MARGIN_LEFT, offset_y, self.number, style, fg, bg)
|
||||||
|
if len(self.number) < 3:
|
||||||
|
ui.display.text(TEXT_MARGIN_LEFT + 20, offset_y, self.word, style, fg, bg)
|
||||||
|
else:
|
||||||
|
ui.display.text(TEXT_MARGIN_LEFT + 30, offset_y, self.word, style, fg, bg)
|
||||||
|
|
||||||
|
def send(self, event, pos):
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user