mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-05-01 13:12:50 +00:00
Amending naming convention
Removing some inconsistencies
This commit is contained in:
@ -14,20 +14,24 @@
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// Menu button with an icon that opens a sub-menu.
|
||||
// Menu button with an icon that opens a sub-menu, i.e. group.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
|
||||
class HomeAssistantViewMenuItem extends WatchUi.IconMenuItem {
|
||||
class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
|
||||
private var mMenu as HomeAssistantView;
|
||||
|
||||
function initialize(definition as Lang.Dictionary, icon as WatchUi.Drawable, options as {
|
||||
function initialize(
|
||||
definition as Lang.Dictionary,
|
||||
icon as WatchUi.Drawable,
|
||||
options as {
|
||||
:alignment as WatchUi.MenuItem.Alignment
|
||||
} or Null) {
|
||||
var label = definition.get("name") as Lang.String;
|
||||
|
||||
var label = definition.get("name") as Lang.String;
|
||||
var identifier = definition.get("entity") as Lang.String;
|
||||
|
||||
WatchUi.IconMenuItem.initialize(
|
@ -123,7 +123,7 @@ class HomeAssistantMenuItemFactory {
|
||||
confirm as Lang.Boolean,
|
||||
data as Lang.Dictionary or Null
|
||||
) as WatchUi.MenuItem {
|
||||
return new HomeAssistantMenuItem(
|
||||
return new HomeAssistantTapMenuItem(
|
||||
label,
|
||||
null,
|
||||
identifier,
|
||||
@ -137,6 +137,6 @@ class HomeAssistantMenuItemFactory {
|
||||
}
|
||||
|
||||
function group(definition as Lang.Dictionary) as WatchUi.MenuItem {
|
||||
return new HomeAssistantViewMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
|
||||
return new HomeAssistantGroupMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
|
||||
class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
||||
class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService;
|
||||
private var mService as Lang.String;
|
||||
private var mConfirm as Lang.Boolean;
|
@ -14,7 +14,7 @@
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// Rendering a Home Assistant Template.
|
||||
// Menu button that renders a Home Assistant Template, and optionally triggers a service.
|
||||
//
|
||||
// Reference:
|
||||
// * https://developers.home-assistant.io/docs/api/rest/
|
||||
|
@ -87,7 +87,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
var lmi = mItems as Lang.Array<WatchUi.MenuItem>;
|
||||
for(var i = 0; i < mItems.size(); i++) {
|
||||
var item = lmi[i];
|
||||
if (item instanceof HomeAssistantViewMenuItem) {
|
||||
if (item instanceof HomeAssistantGroupMenuItem) {
|
||||
fullList.addAll(item.getMenuView().getItemsToUpdate());
|
||||
} else if (item instanceof HomeAssistantToggleMenuItem) {
|
||||
fullList.add(item);
|
||||
@ -150,8 +150,8 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
||||
System.println(haToggleItem.getLabel() + " " + haToggleItem.getId() + " " + haToggleItem.isEnabled());
|
||||
}
|
||||
haToggleItem.setState(haToggleItem.isEnabled());
|
||||
} else if (item instanceof HomeAssistantMenuItem) {
|
||||
var haItem = item as HomeAssistantMenuItem;
|
||||
} else if (item instanceof HomeAssistantTapMenuItem) {
|
||||
var haItem = item as HomeAssistantTapMenuItem;
|
||||
if (Globals.scDebug) {
|
||||
System.println(haItem.getLabel() + " " + haItem.getId());
|
||||
}
|
||||
@ -162,8 +162,8 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
||||
System.println(haItem.getLabel() + " " + haItem.getId());
|
||||
}
|
||||
haItem.callService();
|
||||
} else if (item instanceof HomeAssistantViewMenuItem) {
|
||||
var haMenuItem = item as HomeAssistantViewMenuItem;
|
||||
} else if (item instanceof HomeAssistantGroupMenuItem) {
|
||||
var haMenuItem = item as HomeAssistantGroupMenuItem;
|
||||
if (Globals.scDebug) {
|
||||
System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
||||
}
|
||||
|
Reference in New Issue
Block a user