mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 03:30:02 +00:00
trezor.ui: reset device redesign
This commit is contained in:
parent
2725792528
commit
38c37da0c3
@ -24,8 +24,7 @@ async def layout_apply_settings(session_id, msg):
|
||||
await require_confirm(session_id, Text(
|
||||
'Change label', ui.ICON_RESET,
|
||||
'Do you really want to', 'change label to',
|
||||
ui.BOLD, '%s' % msg.label,
|
||||
ui.NORMAL, '?'))
|
||||
ui.BOLD, '%s' % msg.label))
|
||||
|
||||
if msg.language is not None:
|
||||
await require_confirm(session_id, Text(
|
||||
|
@ -16,7 +16,7 @@ async def layout_recovery_device(session_id, message):
|
||||
msg = 'Please enter ' + nth(message.word_count) + ' word'
|
||||
|
||||
ui.display.clear()
|
||||
ui.header('Recovering device', ui.ICON_RECOVERY, ui.BLACK, ui.LIGHT_GREEN)
|
||||
ui.header('Recovery device', ui.ICON_RECOVERY, ui.BLACK, ui.LIGHT_GREEN)
|
||||
ui.display.text(10, 74, msg, ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
ui.display.text(10, 104, 'of your mnemonic.', ui.BOLD, ui.WHITE, ui.BLACK)
|
||||
|
||||
|
@ -65,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, RecoveryWordText
|
||||
from trezor.ui.text import Text
|
||||
from trezor.messages.ButtonRequestType import ConfirmWord
|
||||
from apps.common.confirm import confirm
|
||||
|
||||
@ -74,23 +74,23 @@ async def show_mnemonic_by_word(session_id, mnemonic):
|
||||
if __debug__:
|
||||
global current_word
|
||||
|
||||
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,
|
||||
content,
|
||||
ConfirmWord)
|
||||
index = 0
|
||||
recovery = True
|
||||
|
||||
for index, word in enumerate(words):
|
||||
while index < len(words):
|
||||
word = words[index]
|
||||
current_word = word
|
||||
content = Container(
|
||||
Text('Recovery seed setup', ui.ICON_RESET, 'Confirm seed word'),
|
||||
RecoveryWordText(index + 1, word))
|
||||
await confirm(session_id,
|
||||
content,
|
||||
ConfirmWord)
|
||||
Text(
|
||||
'Recovery seed setup', ui.ICON_RESET,
|
||||
ui.NORMAL, 'Write down seed word' if recovery else 'Confirm seed word', ' ',
|
||||
ui.BOLD, '%d. %s' % (index + 1, word)),
|
||||
ConfirmWord,
|
||||
'Next', None)
|
||||
index += 1
|
||||
if index == len(words) and recovery:
|
||||
recovery = False
|
||||
index = 0
|
||||
|
||||
|
||||
async def show_mnemonic(mnemonic):
|
||||
|
@ -6,42 +6,48 @@ from .button import CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
|
||||
from .button import CANCEL_BUTTON, CANCEL_BUTTON_ACTIVE
|
||||
from .loader import Loader
|
||||
|
||||
|
||||
CONFIRMED = const(1)
|
||||
CANCELLED = const(2)
|
||||
|
||||
|
||||
class ConfirmDialog(Widget):
|
||||
|
||||
def __init__(self, content=None, confirm='Confirm', cancel='Cancel'):
|
||||
self.content = content
|
||||
self.confirm = Button((121, 240 - 48, 119, 48), confirm,
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
self.cancel = Button((0, 240 - 48, 119, 48), cancel,
|
||||
normal_style=CANCEL_BUTTON,
|
||||
active_style=CANCEL_BUTTON_ACTIVE)
|
||||
if cancel is not None:
|
||||
self.confirm = Button((121, 240 - 48, 119, 48), confirm,
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
self.cancel = Button((0, 240 - 48, 119, 48), cancel,
|
||||
normal_style=CANCEL_BUTTON,
|
||||
active_style=CANCEL_BUTTON_ACTIVE)
|
||||
else:
|
||||
self.cancel = None
|
||||
self.confirm = Button((0, 240 - 48, 240, 48), confirm,
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
|
||||
def render(self):
|
||||
self.confirm.render()
|
||||
self.cancel.render()
|
||||
if self.cancel is not None:
|
||||
self.cancel.render()
|
||||
|
||||
def touch(self, event, pos):
|
||||
if self.confirm.touch(event, pos) == BTN_CLICKED:
|
||||
return CONFIRMED
|
||||
if self.cancel.touch(event, pos) == BTN_CLICKED:
|
||||
return CANCELLED
|
||||
|
||||
if self.cancel is not None:
|
||||
if self.cancel.touch(event, pos) == BTN_CLICKED:
|
||||
return CANCELLED
|
||||
|
||||
async def __iter__(self):
|
||||
return await loop.Wait((super().__iter__(), self.content))
|
||||
|
||||
|
||||
class HoldToConfirmDialog(Widget):
|
||||
|
||||
def __init__(self, content=None, hold='Hold to confirm', *args, **kwargs):
|
||||
self.button = Button((0, 240 - 48, 240, 48), hold,
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
normal_style=CONFIRM_BUTTON,
|
||||
active_style=CONFIRM_BUTTON_ACTIVE)
|
||||
self.content = content
|
||||
self.loader = Loader(*args, **kwargs)
|
||||
|
||||
|
@ -32,25 +32,3 @@ class Text(ui.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
|
||||
|
Loading…
Reference in New Issue
Block a user