Added app setting for left - right menu alignment

This commit is contained in:
SomeoneOnEarth
2023-11-17 20:15:55 +01:00
parent 7bd3486724
commit eab2af72f8
3 changed files with 27 additions and 10 deletions

View File

@ -25,4 +25,6 @@
<property id="config_url" type="string"></property>
<property id="lean_ui" type="boolean"></property>
<property id="menu_alignment" type="boolean"></property>
</properties>

View File

@ -51,4 +51,13 @@
type="boolean"
/>
</setting>
<setting
propertyKey="@Properties.menu_alignment"
title="Left (off) or Right (on) Menu Alignment"
>
<settingConfig
type="boolean"
/>
</setting>
</settings>

View File

@ -24,7 +24,7 @@ using Toybox.WatchUi;
class HomeAssistantMenuItemFactory {
private var mRightLabelAlignement;
private var mMenuItemAlignment;
private var mLabelToggle;
private var strMenuItemTap;
private var bLeanDesign;
@ -43,11 +43,20 @@ class HomeAssistantMenuItemFactory {
bLeanDesign = Application.Properties.getValue("lean_ui") as Lang.Boolean;
mRightLabelAlignement = {:alignment => WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_RIGHT};
var menuItemAlignment = Application.Properties.getValue("menu_alignment") as Lang.Boolean;
if(menuItemAlignment == true){
mMenuItemAlignment = {:alignment => WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_RIGHT};
} else {
mMenuItemAlignment = {:alignment => WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT};
}
strMenuItemTap = WatchUi.loadResource($.Rez.Strings.MenuItemTap);
mTapIcon = new WatchUi.Bitmap({
:rezId=>$.Rez.Drawables.TapIcon
:rezId=>$.Rez.Drawables.TapIcon,
:locX=>WatchUi.LAYOUT_HALIGN_CENTER,
:locY=>WatchUi.LAYOUT_VALIGN_CENTER
});
mMenuIcon = new WatchUi.Bitmap({
@ -55,9 +64,6 @@ class HomeAssistantMenuItemFactory {
:locX=>WatchUi.LAYOUT_HALIGN_CENTER,
:locY=>WatchUi.LAYOUT_VALIGN_CENTER
});
}
static function create() {
@ -79,7 +85,7 @@ class HomeAssistantMenuItemFactory {
subLabel,
identifier,
false,
null
mMenuItemAlignment
);
}
@ -91,7 +97,7 @@ class HomeAssistantMenuItemFactory {
identifier,
service,
mTapIcon,
mRightLabelAlignement
mMenuItemAlignment
);
} else {
@ -100,14 +106,14 @@ class HomeAssistantMenuItemFactory {
strMenuItemTap,
identifier,
service,
null
mMenuItemAlignment
);
}
}
function group(definition as Lang.Dictionary) as WatchUi.MenuItem{
if (bLeanDesign) {
return new HomeAssistantViewIconMenuItem(definition, mMenuIcon, mRightLabelAlignement);
return new HomeAssistantViewIconMenuItem(definition, mMenuIcon, mMenuItemAlignment);
} else {
return new HomeAssistantViewMenuItem(definition);
}