Hi all!
I have a main screen for my watch app - AlarmView.mc and AlarmDelegate.mc, then I created the screen for my watch app such like AlarmScreenView.mc and AlarmScreenDelegate.mc, so I do not understand yet how can open on my watch AlarmScreenView.
Do not clearly understand following: how can I run my watch app in new screen after I pressed the "start" button on my watch instead of displaying the all logic of my watch app on the same screen - on the carousel screen menu app's? What I'm doing wrong?
AlarmDelegate.mc source:
using Toybox.WatchUi as Ui; using Toybox.System as Sys; class AlarmDelegate extends Ui.BehaviorDelegate { var parentView; function initialize() { parentView = view; BehaviorDelegate.initialize(); } function onSelect() { var newView = new AlarmScreenView(); var newDelegate = new AlarmScreenDelegate(newView); Ui.switchToView(newView, newDelegate, Ui.SLIDE_UP); Sys.println("Screen"); return true; } }
AlarmView.mc source:
using Toybox.WatchUi as Ui; class AlarmView extends Ui.View { function initialize() { View.initialize(); } function onLayout(dc) { setLayout(Rez.Layouts.MainLayout(dc)); } function onShow() as Void { } function onUpdate(dc) { } function onHide() as Void { } }
AlarmScreenView.mc sorce:
using Toybox.Graphics as Gfx; using Toybox.WatchUi as Ui; using Toybox.Sensor as Sensor; class AlarmScreenView extends Ui.View { function initialize() { View.initialize(); } function onShow() as Void { } function onUpdate(dc) { var s = Sensor.getInfo(); if (s.heartRate != null) { dc.setColor(Gfx.COLOR_RED, Gfx.COLOR_BLACK); dc.drawText(107, 107, Gfx.FONT_LARGE, "OK", Gfx.TEXT_JUSTIFY_CENTER); } else { dc.setColor(Gfx.COLOR_RED, Gfx.COLOR_BLACK); dc.drawText(107, 107, Gfx.FONT_LARGE, "NOK", Gfx.TEXT_JUSTIFY_CENTER); } } function onHide() as Void { } }
AlarmScreenDelegate.mc source:
using Toybox.WatchUi as Ui; class AlarmScreenDelegate extends Ui.BehaviorDelegate { private var _view as AlarmScreenView function initialize(view as AlarmScreenView) { _view = view; BehaviorDelegate.initialize(); } }
Could someone, please, support with this?
Regards!