implement navigation up

This commit is contained in:
joBr99
2023-11-23 19:12:30 +01:00
parent 9cc31b6e5b
commit 2816fa88e4
2 changed files with 17 additions and 5 deletions

View File

@@ -246,6 +246,14 @@ class HACard(panel_cards.Card):
'color': [255, 255, 255], 'color': [255, 255, 255],
}, self.panel }, self.panel
).render()[1:] ).render()[1:]
if not self.iid_prev and not self.iid_next:
leftBtn = panel_cards.Entity(self.locale,
{
'entity': f'navigate.UP',
'icon': 'mdi:arrow-left-bold',
'color': [255, 255, 255],
}, self.panel
).render()[1:]
result = f"{leftBtn}~{rightBtn}" result = f"{leftBtn}~{rightBtn}"
return result return result

View File

@@ -199,11 +199,15 @@ class LovelaceUIPanel:
match entity_id.split(".")[0]: match entity_id.split(".")[0]:
# handle internal stuff # handle internal stuff
case 'navigate': case 'navigate':
iid = entity_id.split(".")[1] card_iid = entity_id.split(".")[1]
self.privious_cards.append(self.current_card) if card_iid == "UP":
self.current_card = self.searchCard(iid) self.current_card = self.privious_cards.pop()
# TODO Handle privious_cards empty with default card
self.render_current_page(switchPages=True)
else:
self.privious_cards.append(self.current_card)
self.current_card = self.searchCard(card_iid)
self.render_current_page(switchPages=True) self.render_current_page(switchPages=True)
# send ha stuff to ha # send ha stuff to ha
case _: case _:
ha_control.handle_buttons(entity_id, btype, value) ha_control.handle_buttons(entity_id, btype, value)