mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-11 15:12:44 +00:00
refactor(core/homescreen): load homescreen image on-demand
This commit is contained in:
parent
f61d7fffa8
commit
2cb379108c
@ -9,10 +9,12 @@ class HomescreenBase(ui.Layout):
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.label = storage.device.get_label() or "My Trezor"
|
self.label = storage.device.get_label() or "My Trezor"
|
||||||
self.image = storage.device.get_homescreen() or res.load(
|
self.repaint = storage.cache.homescreen_shown is not self.RENDER_INDICATOR
|
||||||
|
|
||||||
|
def get_image(self) -> bytes:
|
||||||
|
return storage.device.get_homescreen() or res.load(
|
||||||
"apps/homescreen/res/bg.toif"
|
"apps/homescreen/res/bg.toif"
|
||||||
)
|
)
|
||||||
self.repaint = storage.cache.homescreen_shown is not self.RENDER_INDICATOR
|
|
||||||
|
|
||||||
def on_render(self) -> None:
|
def on_render(self) -> None:
|
||||||
if not self.repaint:
|
if not self.repaint:
|
||||||
|
@ -52,7 +52,7 @@ class Homescreen(HomescreenBase):
|
|||||||
ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
|
ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
|
||||||
|
|
||||||
# homescreen with shifted avatar and text on bottom
|
# homescreen with shifted avatar and text on bottom
|
||||||
ui.display.avatar(48, 48 - 10, self.image, ui.WHITE, ui.BLACK)
|
ui.display.avatar(48, 48 - 10, self.get_image(), ui.WHITE, ui.BLACK)
|
||||||
ui.display.text_center(ui.WIDTH // 2, 220, self.label, ui.BOLD, ui.FG, ui.BG)
|
ui.display.text_center(ui.WIDTH // 2, 220, self.label, ui.BOLD, ui.FG, ui.BG)
|
||||||
|
|
||||||
def on_touch_start(self, _x: int, _y: int) -> None:
|
def on_touch_start(self, _x: int, _y: int) -> None:
|
||||||
|
@ -41,7 +41,7 @@ class Lockscreen(HomescreenBase):
|
|||||||
ui.display.text_center(
|
ui.display.text_center(
|
||||||
ui.WIDTH // 2, 35, self.label, ui.BOLD, ui.TITLE_GREY, ui.BG
|
ui.WIDTH // 2, 35, self.label, ui.BOLD, ui.TITLE_GREY, ui.BG
|
||||||
)
|
)
|
||||||
ui.display.avatar(48, 48, self.image, ui.WHITE, ui.BLACK)
|
ui.display.avatar(48, 48, self.get_image(), ui.WHITE, ui.BLACK)
|
||||||
|
|
||||||
# lock bar
|
# lock bar
|
||||||
ui.display.bar_radius(40, 100, 160, 40, ui.TITLE_GREY, ui.BG, 4)
|
ui.display.bar_radius(40, 100, 160, 40, ui.TITLE_GREY, ui.BG, 4)
|
||||||
|
Loading…
Reference in New Issue
Block a user