apps/management/reset_device: update styles

pull/25/head
Peter Jensen 6 years ago committed by Jan Pochyla
parent b5220e8675
commit 44ca1ea703

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -8,7 +8,6 @@ if __debug__:
internal_entropy = None
current_word = None
@unimport
async def layout_reset_device(ctx, msg):
from trezor import config
@ -56,10 +55,16 @@ async def layout_reset_device(ctx, msg):
entropy = ehash.digest()
mnemonic = bip39.from_data(entropy[:msg.strength // 8])
warning_content = Text('Backup your seed', ui.ICON_NOCOPY, ui.NORMAL, 'Never make a digital', 'copy of your recovery', 'seed and never upload', 'it online!')
# seed-copy warning
warning_content = Text('Backup your seed', ui.ICON_NOCOPY, ui.NORMAL,
'Never make a digital',
'copy of your recovery',
'seed and never upload',
'it online!')
await require_confirm(ctx, warning_content, ButtonRequestType.ResetDevice)
await show_mnemonic(ctx, mnemonic)
await show_mnemonic(mnemonic)
if curpin != newpin:
config.change_pin(curpin, newpin)
@ -99,7 +104,7 @@ async def show_mnemonic_by_word(ctx, mnemonic):
ConfirmWord, confirm='Next', cancel=None)
async def show_mnemonic(ctx, mnemonic):
async def show_mnemonic(mnemonic):
from trezor.ui.scroll import paginate
first_page = const(0)
@ -111,20 +116,17 @@ async def show_mnemonic(ctx, mnemonic):
async def show_mnemonic_page(page, page_count, mnemonic):
from trezor.ui.button import Button
from trezor.ui.scroll import render_scrollbar, animate_swipe
ui.display.clear()
ui.header('Write down seed', ui.ICON_RESET, ui.FG, ui.BG)
render_scrollbar(page, page_count)
from trezor.ui.text import Text
from trezor.ui.scroll import Scrollpage, animate_swipe
lines = []
for pi, (wi, word) in enumerate(mnemonic[page]):
top = pi * 35 + 68
pos = wi + 1
offset = 0
if pos > 9:
offset += 12
ui.display.text(10, top, '%d.' % pos, ui.BOLD, ui.LIGHT_GREEN, ui.BG)
ui.display.text(30 + offset, top, '%s' % word, ui.BOLD, ui.FG, ui.BG)
lines.append(str('%d. %s' % (pos, word)))
ui.display.clear()
scroll_page = Scrollpage(Text('Recovery seed setup', ui.ICON_RESET, ui.MONO, lines), page, page_count)
scroll_page.render()
if page + 1 == page_count:
await Button(

Binary file not shown.

@ -1,5 +1,5 @@
from micropython import const
from trezor import loop, ui
from trezor import loop, ui, res
from .swipe import Swipe, SWIPE_UP, SWIPE_DOWN, SWIPE_VERTICAL
@ -37,17 +37,15 @@ async def animate_swipe():
sleep = loop.sleep(time_delay)
for t in ui.pulse(draw_delay):
fg = ui.blend(ui.GREY, ui.DARK_GREY, t)
ui.display.bar_radius(102, 214, 36, 4, fg, ui.BG, 2)
ui.display.bar_radius(106, 222, 28, 4, fg, ui.BG, 2)
ui.display.bar_radius(110, 230, 20, 4, fg, ui.BG, 2)
ui.display.icon(110, 210, res.load(ui.ICON_SWIPE), fg, ui.BG)
await sleep
def render_scrollbar(page, page_count):
bbox = const(220)
size = const(10)
size = const(8)
padding = 18
padding = 14
if page_count * padding > bbox:
padding = bbox // page_count
@ -62,11 +60,16 @@ def render_scrollbar(page, page_count):
size, ui.FG, ui.BG, 4)
class Scrollbar(ui.Widget):
class Scrollpage(ui.Widget):
def __init__(self, page, page_count):
def __init__(self, content, page, page_count):
self.content = content
self.page = page
self.page_count = page_count
def render(self):
self.content.render()
render_scrollbar(self.page, self.page_count)
async def __iter__(self):
return await loop.wait(super().__iter__(), self.content)

@ -56,6 +56,7 @@ ICON_SEND = 'trezor/res/send.toig'
ICON_CLICK = 'trezor/res/click.toig'
ICON_BACK = 'trezor/res/left.toig'
ICON_NOCOPY = 'trezor/res/nocopy.toig'
ICON_SWIPE = 'trezor/res/swipedown.toig'
# buttons
BTN_DEFAULT = {

@ -22,11 +22,20 @@ class Text(ui.Widget):
bg = ui.BG
ui.header(self.header_text, self.header_icon, ui.TITLE_GREY, ui.BG, self.icon_color)
for item in self.content:
if isinstance(item, str):
ui.display.text(offset_x, offset_y, item, style, fg, bg)
def process(eitem):
nonlocal offset_y
nonlocal style
nonlocal fg
if isinstance(eitem, str):
ui.display.text(offset_x, offset_y, eitem, style, fg, bg)
offset_y += TEXT_LINE_HEIGHT
elif item == ui.MONO or item == ui.NORMAL or item == ui.BOLD:
style = item
elif isinstance(eitem, (tuple, list, dict, set)):
for i in eitem:
process(i)
elif eitem == ui.MONO or eitem == ui.NORMAL or eitem == ui.BOLD:
style = eitem
else:
fg = item
fg = eitem
for item in self.content:
process(item)

Loading…
Cancel
Save