Amending naming convention

Removing some inconsistencies
This commit is contained in:
Philip Abbey
2024-01-19 16:11:30 +00:00
parent 6632ba6c41
commit 67a5f0a14e
5 changed files with 17 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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());
}