1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

replace scrolling to componenet, added mockup for recovery device layout

This commit is contained in:
chren 2016-06-10 17:07:17 +02:00 committed by Pavol Rusnak
parent 887c877567
commit 771372adb2
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 61 additions and 18 deletions

View File

@ -26,6 +26,13 @@ def dispatch_WipeDevice(mtype, mbuf):
return layout_wipe_device(message)
@unimport_func
def dispatch_RecoveryDevice(mtype, mbuf):
from trezor.messages.RecoveryDevice import RecoveryDevice
message = RecoveryDevice.loads(mbuf)
from .layout_recovery_device import layout_recovery_device
return layout_recovery_device(message)
def boot():
LoadDevice = 13
register(LoadDevice, dispatch_LoadDevice)
@ -33,3 +40,5 @@ def boot():
register(ResetDevice, dispatch_ResetDevice)
WipeDevice = 5
register(WipeDevice, dispatch_WipeDevice)
RecoveryDevice = 45
register(RecoveryDevice, dispatch_RecoveryDevice)

View File

@ -0,0 +1,16 @@
from trezor import ui, loop, wire
from trezor.utils import unimport_gen
def ord(n):
return str(n)+("th" if 4<=n%100<=20 else {1:"st",2:"nd",3:"rd"}.get(n%10, "th"))
@unimport_gen
def layout_recovery_device(message):
msg = 'Please enter ' + ord(message.word_count) + ' word'
ui.clear()
ui.display.text(10, 30, 'Recovering device', ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
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)
yield from wire.read(None)

View File

@ -1,6 +1,7 @@
from trezor import wire, loop, res, ui
from trezor.ui.swipe import Swipe, SWIPE_UP, SWIPE_DOWN
from trezor.ui.button import Button, CONFIRM_BUTTON, CONFIRM_BUTTON_ACTIVE
from trezor.ui.scroll import Scroll
from trezor.crypto import hashlib, random, bip39
from trezor.utils import unimport_gen
@ -62,23 +63,8 @@ def layout_reset_device(m):
ui.display.text_right(40, top, '%d.' % (index + 1), ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
ui.display.text(45, top, '%s' % word, ui.BOLD, ui.WHITE, ui.BLACK)
# print side scrolling indicator
count = len(mnemonic_words) // words_per_page # 6
padding = 20
screen_height = const(220)
cursor = 8
if count * padding > screen_height:
padding = screen_height // count
x = 220
y = (10 + (screen_height // 2)) - ((count // 2) * padding)
for i in range(0, count):
if (i != page):
ui.display.bar(x, y + i * padding, cursor, cursor, ui.GREY)
ui.display.bar(x, y + page * padding, cursor, cursor, ui.WHITE)
scroll = Scroll(page=page, totale_lines=mnemonic_words, lines_per_page=words_per_page)
scroll.render()
# TODO: remove swipedown icon when this button is showed

View File

@ -8,7 +8,7 @@ from trezor.workflows.confirm import confirm
def layout_wipe_device(message):
ui.clear()
ui.display.text(10, 30, 'Wipe device', ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
ui.display.text(10, 30, 'Wiping device', ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
ui.display.text(10, 74, 'Do you really want to', ui.BOLD, ui.WHITE, ui.BLACK)
ui.display.text(10, 104, 'wipe the device?', ui.BOLD, ui.WHITE, ui.BLACK)
ui.display.text(10, 164, 'All data will be lost.', ui.NORMAL, ui.WHITE, ui.BLACK)

32
src/trezor/ui/scroll.py Normal file
View File

@ -0,0 +1,32 @@
from . import display
from trezor import ui, loop, res
class Scroll():
def __init__(self, page=0, totale_lines=0, lines_per_page=4):
self.page = page
self.totale_lines = totale_lines
self.lines_per_page = lines_per_page
def render(self):
count = len(self.totale_lines) // self.lines_per_page
padding = 20
screen_height = const(220)
cursor = 8
if count * padding > screen_height:
padding = screen_height // count
x = 220
y = (10 + (screen_height // 2)) - ((count // 2) * padding)
for i in range(0, count):
if (i != self.page):
ui.display.bar(x, y + i * padding, cursor, cursor, ui.GREY)
ui.display.bar(x, y + self.page * padding, cursor, cursor, ui.WHITE)
def wait(self):
while True:
self.render()