From 44ca1ea70330a7703e46571d298ba6038891b975 Mon Sep 17 00:00:00 2001 From: Peter Jensen Date: Wed, 17 Jan 2018 17:42:55 +0100 Subject: [PATCH] apps/management/reset_device: update styles --- assets/swipedown.png | Bin 0 -> 1303 bytes src/apps/management/reset_device.py | 32 +++++++++++++++------------- src/trezor/res/swipedown.toig | Bin 0 -> 137 bytes src/trezor/ui/scroll.py | 19 ++++++++++------- src/trezor/ui/style.py | 1 + src/trezor/ui/text.py | 21 ++++++++++++------ 6 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 assets/swipedown.png create mode 100644 src/trezor/res/swipedown.toig diff --git a/assets/swipedown.png b/assets/swipedown.png new file mode 100644 index 0000000000000000000000000000000000000000..00af05f40cf59e67ed64cfc339b1a807dec5f4a9 GIT binary patch literal 1303 zcmV+y1?c*TP)U8P*7-ZbZ>KLZ*U+lnSp_Ufq@}0xwybFAi#%#fq@|}KQEO56)-X|e7nZL z$iTqBa9P*U#mSX{G{Bl%P*lRez;J+pfx##xwK$o9f#C}S14DXwNkIt%17i#W1A|CX zc0maP17iUL1A|C*NRTrF17iyV0~1e4YDEbH0|SF|enDkXW_m`6f}y3QrGjHhep0GJ zaAk2xYHqQDXI^rCQ9*uDVo7QW0|Nup4h9AW240u^5(W3f%sd4n162kpgNVo|1qcff zJ_s=cNG>fZg9jx8g8+j9g8_pBLjXe}Lp{R+hNBE`7{wV~7)u#fFy3PlV+vxLz;uCG zm^qSpA@ds+OO_6nTdaDlt*rOhEZL^9ePa)2-_4=K(Z%tFGm-NGmm}8}ZcXk5JW@PU zd4+f<@d@)yL(o<5icqT158+-B6_LH7;i6x}CW#w~Uy-Pgl#@Irl`kzV zeL|*8R$ca%T%Wv){2zs_iiJvgN^h0dsuZZ2sQy$tsNSU!s;Q*;LF<6_B%M@UD?LHI zSNcZ`78uqV#TeU~$eS{ozBIdFzSClfs*^S+dw;4dus<{M;#|MXC)T}S9v!D zcV!QCPhBq)ZyO(X-(bH4|NMaZz==UigLj2o41F2S6d@OB6%`R(5i>J(Puzn9wnW{e zu;hl6HK{k#IWjCVGqdJqU(99Cv(K+6*i`tgSi2;vbXD1#3jNBGs$DgVwO(~o>mN4i zHPtkqZIx>)Y(Ls5-Br|mx>vQYvH$Kwn@O`L|D75??eGkZnfg$5<;Xeg_o%+-I&+-3%01W^SH2RkDT>t<8AY({UO#lFTB>(_`g8%^e z{{R4h=>PzAFaQARU;qF*m;eA5Z<1fdMgRZ-c}YY;RCwBA6#B`)$o+)@00030|6=6+ z-_EG^{xtvq0RR7DRK3N>;Jb;D`>XdBMg{-?009601i>)@03Zy&u=d3nvQaQOJ4@ny zNQN{L>=8mf00030|6(*f#lXnGz`($eGMj;soBt^T10#dQafTO?j9lLsERQiTFfcGO zK$RrUV`N}pU;vObhgJxJQ2>R%S3wiaU|;|n)dg&_fDFMDPC+pmUBF5+o6HnVrbqbe zJ@=j)^?1#KhFknLmkFeEyj!OSl3n<2b+e@T2T8NA|5Q;74li|-*6~SIKH1-4Woiyt z8VchuivRv#koS$ks)$84kS$Ivf>{iFprep8*udou3ur*{)t>V{XBryhw}w|H#btG z3Y{6O;~37qkRzAiX0pGyn1cLUK<^p1<2~g#+Nz@tc&Z*l9cmoz1^{D=R7*v#{s;g7 N002ovPDHLkV1kz(HhKU6 literal 0 HcmV?d00001 diff --git a/src/apps/management/reset_device.py b/src/apps/management/reset_device.py index 05c39c7971..44fdeba0e2 100644 --- a/src/apps/management/reset_device.py +++ b/src/apps/management/reset_device.py @@ -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( diff --git a/src/trezor/res/swipedown.toig b/src/trezor/res/swipedown.toig new file mode 100644 index 0000000000000000000000000000000000000000..0b5707ddf2bd7c3fef33a04819af15a2bab675b0 GIT binary patch literal 137 zcmV;40CxXWPf2GO01yCu0000jj=>GWKnw);LW0CE9gqeP*FkvlOAB;B3sgZrR6q?> zfCA(f80`4`utxHFciW@NTvNp 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) diff --git a/src/trezor/ui/style.py b/src/trezor/ui/style.py index 42cef048d1..7e21370dfe 100644 --- a/src/trezor/ui/style.py +++ b/src/trezor/ui/style.py @@ -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 = { diff --git a/src/trezor/ui/text.py b/src/trezor/ui/text.py index 3d8338312d..688aca8648 100644 --- a/src/trezor/ui/text.py +++ b/src/trezor/ui/text.py @@ -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)