1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-16 17:42:02 +00:00

simplify the Text interface

This commit is contained in:
Jan Pochyla 2016-09-27 16:30:08 +02:00 committed by Pavol Rusnak
parent eea88f9bae
commit 35d53ad7fc
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 12 additions and 10 deletions

View File

@ -12,10 +12,8 @@ async def layout_wipe_device(message, session_id):
ui.clear() ui.clear()
content = Text('Wiping device', content = Text('Wiping device',
(ui.BOLD, 'Do you really want to'), ui.BOLD, 'Do you really want to', 'wipe the device?',
(ui.BOLD, 'wipe the device?'), ui.NORMAL, '', 'All data will be lost.')
(ui.NORMAL, ''),
(ui.NORMAL, 'All data will be lost.'))
await hold_to_confirm(session_id, content) await hold_to_confirm(session_id, content)
clear_storage(session_id) clear_storage(session_id)

View File

@ -7,19 +7,23 @@ TEXT_MARGIN_LEFT = const(10)
class Text: class Text:
def __init__(self, header, *lines): def __init__(self, header, *content):
self.header = header self.header = header
self.lines = lines self.content = content
def render(self): def render(self):
offset = TEXT_LINE_HEIGHT offset = TEXT_LINE_HEIGHT
ui.display.text(TEXT_MARGIN_LEFT, offset, ui.display.text(TEXT_MARGIN_LEFT, offset,
self.header, ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) self.header, ui.BOLD, ui.LIGHT_GREEN, ui.BLACK)
offset += TEXT_HEADER_HEIGHT offset += TEXT_HEADER_HEIGHT
for style, line in self.lines: style = ui.NORMAL
ui.display.text(TEXT_MARGIN_LEFT, offset, for item in self.content:
line, style, ui.WHITE, ui.BLACK) if isinstance(item, str):
offset += TEXT_LINE_HEIGHT ui.display.text(TEXT_MARGIN_LEFT, offset,
item, style, ui.WHITE, ui.BLACK)
offset += TEXT_LINE_HEIGHT
else:
style = item
def send(self, event, pos): def send(self, event, pos):
pass pass