so basic question I´m using the simple data field menu sample to change settings on a watch face, so I just need to change a couple of variables, all works fine but variables back to true when apply, what I'm doing wrong?'
//
// Copyright 2016-2021 by Garmin Ltd. or its subsidiaries.
// Subject to Garmin SDK License Agreement and Wearables
// Application Developer Agreement.
//
import Toybox.Application.Storage;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.WatchUi;
var mod1 = true;
var mod2 = true;
//! Initial view for the settings
class DataFieldSettingsView extends WatchUi.View {
//! Constructor
public function initialize() {
View.initialize();
}
//! Update the view
//! @param dc Device context
public function onUpdate(dc as Dc) as Void {
dc.clearClip();
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
dc.clear();
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
dc.drawText(dc.getWidth() / 2, dc.getHeight() / 2 - 30, Graphics.FONT_SMALL, "Press Menu \nfor settings", Graphics.TEXT_JUSTIFY_CENTER);
}
}
//! Handle opening the settings menu
class DataFieldSettingsDelegate extends WatchUi.BehaviorDelegate {
//! Constructor
public function initialize() {
BehaviorDelegate.initialize();
}
//! Handle the menu event
//! @return true if handled, false otherwise
public function onMenu() as Boolean {
var menu = new $.DataFieldSettingsMenu();
mod1 = Storage.getValue(1) ? false : true;
menu.addItem(new WatchUi.ToggleMenuItem("Dark Shift Mode", null, 1, mod1, null));
mod2 = Storage.getValue(2) ? false : true;
menu.addItem(new WatchUi.ToggleMenuItem("Low Power Mode", null, 2, mod2, null));
WatchUi.pushView(menu, new $.DataFieldSettingsMenuDelegate(), WatchUi.SLIDE_IMMEDIATE);
return true;
}
}