128 lines
2.6 KiB
MonkeyC
128 lines
2.6 KiB
MonkeyC
import Toybox.Lang;
|
|
import Toybox.WatchUi;
|
|
|
|
|
|
|
|
class KittieCatsSettingsView extends WatchUi.Menu2
|
|
{
|
|
private var themeMenuItem;
|
|
|
|
|
|
function initialize()
|
|
{
|
|
Menu2.initialize(null);
|
|
Menu2.setTitle(Rez.Strings.SettingsTitle);
|
|
|
|
self.themeMenuItem = new WatchUi.MenuItem(Rez.Strings.SettingsTheme, "", "theme", null);
|
|
Menu2.addItem(self.themeMenuItem);
|
|
|
|
// TODO add settings for low power mode
|
|
}
|
|
|
|
|
|
function onShow()
|
|
{
|
|
var currentTheme = ThemeManager.getInstance().getLocalizedCurrentTheme();
|
|
self.themeMenuItem.setSubLabel(currentTheme.Name);
|
|
}
|
|
}
|
|
|
|
|
|
class KittieCatsSettingsMenuDelegate extends WatchUi.Menu2InputDelegate
|
|
{
|
|
function initialize()
|
|
{
|
|
Menu2InputDelegate.initialize();
|
|
}
|
|
|
|
|
|
function onSelect(item)
|
|
{
|
|
var id = item.getId();
|
|
|
|
switch (id)
|
|
{
|
|
case "theme":
|
|
{
|
|
var themes = ThemeManager.getInstance().getLocalizedThemes();
|
|
var currentTheme = ThemeManager.getInstance().getLocalizedCurrentTheme();
|
|
|
|
// Not sure if I like the picker UI, but it'll do for now
|
|
WatchUi.pushView(new Picker({
|
|
:title => new WatchUi.Text({ :text => Rez.Strings.SettingsTheme }),
|
|
:pattern => [new ThemePickerFactory(themes)],
|
|
:defaults => [themes.indexOf(currentTheme)]
|
|
}), new ThemePickerDelegate(), WatchUi.SLIDE_LEFT);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function onBack()
|
|
{
|
|
WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class ThemePickerFactory extends WatchUi.PickerFactory
|
|
{
|
|
private var themes as Array<ThemeInfo>;
|
|
|
|
|
|
function initialize(themes)
|
|
{
|
|
PickerFactory.initialize();
|
|
|
|
self.themes = themes;
|
|
}
|
|
|
|
|
|
function getDrawable(item, isSelected)
|
|
{
|
|
return new WatchUi.Text({
|
|
:text => self.themes[item].Name,
|
|
:color => Graphics.COLOR_WHITE,
|
|
:font => Graphics.FONT_SMALL,
|
|
:justification => Graphics.TEXT_JUSTIFY_LEFT
|
|
});
|
|
}
|
|
|
|
|
|
function getSize()
|
|
{
|
|
return self.themes.size();
|
|
}
|
|
|
|
|
|
function getValue(item)
|
|
{
|
|
return self.themes[item].Id;
|
|
}
|
|
}
|
|
|
|
|
|
class ThemePickerDelegate extends WatchUi.PickerDelegate
|
|
{
|
|
function initialize()
|
|
{
|
|
PickerDelegate.initialize();
|
|
}
|
|
|
|
|
|
function onAccept(values)
|
|
{
|
|
ThemeManager.getInstance().setCurrentThemeId(values[0]);
|
|
|
|
WatchUi.popView(WatchUi.SLIDE_DOWN);
|
|
return true;
|
|
}
|
|
|
|
function onCancel()
|
|
{
|
|
return true;
|
|
}
|
|
} |