From 8f4bbb8825e22b089bfd566bbd73c95f937865a8 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Wed, 10 Jul 2019 12:12:06 +0200 Subject: [PATCH] core/homescreen: move err and warn to ui module --- core/src/apps/homescreen/homescreen.py | 22 +++++----------------- core/src/trezor/ui/__init__.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/core/src/apps/homescreen/homescreen.py b/core/src/apps/homescreen/homescreen.py index 3ba4cee35..7502788bb 100644 --- a/core/src/apps/homescreen/homescreen.py +++ b/core/src/apps/homescreen/homescreen.py @@ -29,28 +29,16 @@ def display_homescreen() -> None: image = res.load("apps/homescreen/res/bg.toif") if storage.is_initialized() and storage.device.no_backup(): - _err("SEEDLESS") + ui.header_error("SEEDLESS") elif storage.is_initialized() and storage.device.unfinished_backup(): - _err("BACKUP FAILED!") + ui.header_error("BACKUP FAILED!") elif storage.is_initialized() and storage.device.needs_backup(): - _warn("NEEDS BACKUP!") + ui.header_warning("NEEDS BACKUP!") elif storage.is_initialized() and not config.has_pin(): - _warn("PIN NOT SET!") + ui.header_warning("PIN NOT SET!") elif storage.slip39.is_in_progress(): - _warn("SHAMIR IN PROGRESS!") + ui.header_warning("SHAMIR IN PROGRESS!") else: ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG) ui.display.avatar(48, 48 - 10, image, ui.WHITE, ui.BLACK) ui.display.text_center(ui.WIDTH // 2, 220, label, ui.BOLD, ui.FG, ui.BG) - - -def _warn(message: str) -> None: - ui.display.bar(0, 0, ui.WIDTH, 30, ui.YELLOW) - ui.display.text_center(ui.WIDTH // 2, 22, message, ui.BOLD, ui.BLACK, ui.YELLOW) - ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG) - - -def _err(message: str) -> None: - ui.display.bar(0, 0, ui.WIDTH, 30, ui.RED) - ui.display.text_center(ui.WIDTH // 2, 22, message, ui.BOLD, ui.WHITE, ui.RED) - ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG) diff --git a/core/src/trezor/ui/__init__.py b/core/src/trezor/ui/__init__.py index 9c6c5cc0c..cafe1691e 100644 --- a/core/src/trezor/ui/__init__.py +++ b/core/src/trezor/ui/__init__.py @@ -108,6 +108,18 @@ def header( display.text(44, 35, title, BOLD, fg, bg) +def header_warning(message: str) -> None: + display.bar(0, 0, WIDTH, 30, style.YELLOW) + display.text_center(WIDTH // 2, 22, message, BOLD, style.BLACK, style.YELLOW) + display.bar(0, 30, WIDTH, HEIGHT - 30, style.BG) + + +def header_error(message: str) -> None: + display.bar(0, 0, WIDTH, 30, style.RED) + display.text_center(WIDTH // 2, 22, message, BOLD, style.WHITE, style.RED) + display.bar(0, 30, WIDTH, HEIGHT - 30, style.BG) + + def grid( i: int, n_x: int = 3,