mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-05-02 05:32:27 +00:00
Refactored icon submenu creation
This commit is contained in:
@ -31,6 +31,8 @@ class HomeAssistantMenuItemFactory {
|
||||
|
||||
private var mTapIcon;
|
||||
|
||||
private var mMenuIcon;
|
||||
|
||||
private static var instance;
|
||||
|
||||
private function initialize() {
|
||||
@ -48,6 +50,14 @@ class HomeAssistantMenuItemFactory {
|
||||
:rezId=>$.Rez.Drawables.TapIcon
|
||||
});
|
||||
|
||||
mMenuIcon = new WatchUi.Bitmap({
|
||||
:rezId=>Rez.Drawables.MenuIcon,
|
||||
:locX=>WatchUi.LAYOUT_HALIGN_CENTER,
|
||||
:locY=>WatchUi.LAYOUT_VALIGN_CENTER
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static function create() {
|
||||
@ -97,7 +107,7 @@ class HomeAssistantMenuItemFactory {
|
||||
|
||||
function group(definition as Lang.Dictionary) as WatchUi.MenuItem{
|
||||
if (bLeanDesign) {
|
||||
return new HomeAssistantViewIconMenuItem(definition);
|
||||
return new HomeAssistantViewIconMenuItem(definition, mMenuIcon, mRightLabelAlignement);
|
||||
} else {
|
||||
return new HomeAssistantViewMenuItem(definition);
|
||||
}
|
||||
|
@ -24,24 +24,18 @@ using Toybox.WatchUi;
|
||||
class HomeAssistantViewIconMenuItem extends WatchUi.IconMenuItem {
|
||||
hidden var mMenu as HomeAssistantView;
|
||||
|
||||
function initialize(definition as Lang.Dictionary) {
|
||||
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 identifier = definition.get("entity") as Lang.String;
|
||||
|
||||
var icon = new WatchUi.Bitmap({
|
||||
:rezId=>Rez.Drawables.MenuIcon,
|
||||
:locX=>WatchUi.LAYOUT_HALIGN_CENTER,
|
||||
:locY=>WatchUi.LAYOUT_VALIGN_CENTER
|
||||
});
|
||||
|
||||
var alignement = {:alignment => WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_RIGHT};
|
||||
|
||||
WatchUi.IconMenuItem.initialize(
|
||||
label,
|
||||
null,
|
||||
identifier,
|
||||
icon,
|
||||
alignement
|
||||
options
|
||||
);
|
||||
|
||||
mMenu = new HomeAssistantView(definition, null);
|
||||
|
Reference in New Issue
Block a user