Initial Partial View
When the initial view is shown for a widget, then you must use clear on 920xt but not in the simulator... Without the clear, the view is grabbed ;)
using Toybox.Application as App;
using Toybox.WatchUi as UI;
using Toybox.Graphics as G;
using Toybox.Timer;
class TestSwitchViewApp extends App.AppBase {
function onStart() {
}
function onStop() {
}
function getInitialView() {
return [ new View1() ];
}
}
class View1 extends UI.View {
function onLayout(dc) {
}
function onShow() {
}
function onUpdate(dc) {
dc.setColor(G.COLOR_GREEN, G.COLOR_RED);
//dc.clear();
dc.drawText(dc.getWidth()/2, dc.getHeight()/2, G.FONT_MEDIUM, "Hello", G.TEXT_JUSTIFY_CENTER|G.TEXT_JUSTIFY_VCENTER);
}
function onHide() {
}
function nextView() {
UI.switchToView(new View2(), null, UI.SLIDE_IMMEDIATE);
}
}
Images are inverted
I have noticed that images are inverted.
using Toybox.Application as App;
using Toybox.WatchUi as UI;
using Toybox.Graphics as G;
using Toybox.Timer;
class TestSwitchViewApp extends App.AppBase {
function onStart() {
}
function onStop() {
}
function getInitialView() {
return [ new View1() ];
}
}
class View1 extends UI.View {
var logo;
function onLayout(dc) {
logo = UI.loadResource(Rez.Drawables.id_monkey);
}
function onShow() {
}
function onUpdate(dc) {
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_WHITE);
dc.clear();
dc.drawBitmap(0, 0, logo);
}
function onHide() {
}
}
Timer does not seem to work
Timers does not seem to work in 920xt - but works properly in the simulator.
An example:
using Toybox.Application as App;
using Toybox.WatchUi as UI;
using Toybox.Graphics as G;
using Toybox.Timer;
class TestSwitchViewApp extends App.AppBase {
function onStart() {
}
function onStop() {
}
function getInitialView() {
return [ new View1() ];
}
}
class View1 extends UI.View {
function onLayout(dc) {
new Timer.Timer().start(method(:nextView), 2000, false);
}
function onShow() {
}
function onUpdate(dc) {
dc.setColor(G.COLOR_GREEN, G.COLOR_RED);
dc.clear();
dc.drawText(dc.getWidth()/2, dc.getHeight()/2, G.FONT_MEDIUM, "Hello", G.TEXT_JUSTIFY_CENTER|G.TEXT_JUSTIFY_VCENTER);
}
function onHide() {
}
function nextView() {
UI.switchToView(new View2(), null, UI.SLIDE_IMMEDIATE);
}
}
class View2 extends UI.View {
function onLayout(dc) {
new Timer.Timer().start(method(:nextView), 2000, false);
}
function onShow() {
}
function onUpdate(dc) {
dc.setColor(G.COLOR_RED, G.COLOR_GREEN);
dc.clear();
dc.drawText(dc.getWidth()/2, dc.getHeight()/2, G.FONT_MEDIUM, "World", G.TEXT_JUSTIFY_CENTER|G.TEXT_JUSTIFY_VCENTER);
}
function onHide() {
}
function nextView() {
UI.switchToView(new View1(), null, UI.SLIDE_IMMEDIATE);
}
}