From d47e9fb855186cdb8b503030e48f53c28fb030e4 Mon Sep 17 00:00:00 2001 From: Peter Jensen Date: Tue, 28 Mar 2017 19:08:48 +0200 Subject: [PATCH] trezor.ui: prototype of seed setup --- src/apps/management/reset_device.py | 15 ++++++++++----- src/trezor/ui/text.py | 25 +++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/apps/management/reset_device.py b/src/apps/management/reset_device.py index cd1c46d188..6f7954502c 100644 --- a/src/apps/management/reset_device.py +++ b/src/apps/management/reset_device.py @@ -1,5 +1,6 @@ from micropython import const from trezor import wire, ui +from trezor.ui.container import Container from trezor.utils import unimport, chunks import ubinascii @@ -64,7 +65,7 @@ async def layout_reset_device(session_id, msg): 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 apps.common.confirm import confirm @@ -75,16 +76,20 @@ async def show_mnemonic_by_word(session_id, mnemonic): for index, word in enumerate(words): current_word = word + content = Container( + Text('Recovery seed setup', ui.ICON_RESET, 'Write down seed word'), + RecoveryWordText(index + 1, word)) await confirm(session_id, - Text('Write down seed', ui.ICON_RESET, - '%d. %s' % (index, word)), + content, ConfirmWord) for index, word in enumerate(words): current_word = word + content = Container( + Text('Recovery seed setup', ui.ICON_RESET, 'Confirm seed word'), + RecoveryWordText(index + 1, word)) await confirm(session_id, - Text('Confirm seed', ui.ICON_RESET, - '%d. %s' % (index, word)), + content, ConfirmWord) diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index 5ef9569e70..f2cf7a9d4e 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -1,13 +1,12 @@ from micropython import const from trezor import ui -from trezor.ui import Widget TEXT_HEADER_HEIGHT = const(32) TEXT_LINE_HEIGHT = const(23) TEXT_MARGIN_LEFT = const(10) -class Text(Widget): +class Text(ui.Widget): def __init__(self, header_text, header_icon, *content): self.header_text = header_text @@ -33,3 +32,25 @@ class Text(Widget): def send(self, event, pos): 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