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="config_url" type="string"></property>
<property id="lean_ui" type="boolean"></property> <property id="lean_ui" type="boolean"></property>
<property id="menu_alignment" type="boolean"></property>
</properties> </properties>

View File

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

View File

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