Skip to content

Commit

Permalink
SFT-2348: fixed card header icons
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Jun 21, 2023
1 parent eea29dd commit d2d0679
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 6 additions & 2 deletions ports/stm32/boards/Passport/modules/views/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def set_header(self,
self.update()

def update(self):
from utils import derive_icon

# Always update the color and top padding
top_pad = CARD_HEADER_HEIGHT if self.is_header_visible() else CARD_BORDER_WIDTH
with LocalStyle(self.card_border) as style:
Expand All @@ -199,7 +201,8 @@ def update(self):
# default.bg_color(GREEN, 128)

if self.icon is not None:
self.icon_view = Image(self.icon, color=self.header_fg_color)
icon = derive_icon(self.icon)
self.icon_view = Image(icon, color=self.header_fg_color)
with Stylize(self.icon_view) as default:
default.align(lv.ALIGN.LEFT_MID)
self.header.add_child(self.icon_view)
Expand All @@ -212,7 +215,8 @@ def update(self):
self.header.add_child(header_title)

if self.right_icon is not None:
self.right_icon_view = Image(self.right_icon, color=self.header_fg_color)
right_icon = derive_icon(self.right_icon)
self.right_icon_view = Image(right_icon, color=self.header_fg_color)
with Stylize(self.right_icon_view) as default:
default.align(lv.ALIGN.RIGHT_MID)
self.header.add_child(self.right_icon_view)
Expand Down
7 changes: 3 additions & 4 deletions ports/stm32/boards/Passport/modules/views/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ def __init__(self, icon, color=None, opa=None):
default.opa(self.opa)

def set_icon(self, icon):
if isinstance(icon, str):
self.icon = getattr(lv, icon)
else:
self.icon = icon
from utils import derive_icon

self.icon = derive_icon(icon)
self.update()

def set_color(self, color=None, opa=None):
Expand Down

0 comments on commit d2d0679

Please sign in to comment.