1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

core/homescreen: move err and warn to ui module

This commit is contained in:
Tomas Susanka 2019-07-10 12:12:06 +02:00
parent cd439af1a6
commit 8f4bbb8825
2 changed files with 17 additions and 17 deletions

View File

@ -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)

View File

@ -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,