update
This commit is contained in:
1 parent
f7bcbc53ef
commit
65b26786a0
39 files changed
+4710
-3044
No files matched your search
@@ -0,0 +1,83 @@
|
||||
import Toybox.WatchUi;
|
||||
import Toybox.Graphics;
|
||||
import Toybox.Lang;
|
||||
|
||||
class menuConfirmationDelegate extends WatchUi.View {
|
||||
private var _message as String;
|
||||
private var _showCancel as Boolean;
|
||||
|
||||
function initialize(message as String, showCancel as Boolean) {
|
||||
View.initialize();
|
||||
_message = message;
|
||||
_showCancel = showCancel;
|
||||
}
|
||||
|
||||
function onUpdate(dc as Dc) as Void {
|
||||
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
|
||||
dc.clear();
|
||||
dc.setPenWidth(4);
|
||||
|
||||
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(
|
||||
$.gX,
|
||||
$.gY,
|
||||
$.gFontScore,
|
||||
_message,
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER
|
||||
);
|
||||
|
||||
dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawArc($.gX, $.gY, $.gR, Graphics.ARC_CLOCKWISE, 40, 20);
|
||||
dc.setColor(Graphics.COLOR_DK_GREEN, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(
|
||||
$.gX,
|
||||
$.gH * 0.25,
|
||||
$.gFontScore,
|
||||
"Confirm",
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER
|
||||
);
|
||||
if (_showCancel){
|
||||
// Bottom Right: Back Button (Cancel Action)
|
||||
dc.setColor(Graphics.COLOR_DK_RED , Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawArc($.gX, $.gY, $.gR, Graphics.ARC_CLOCKWISE, -20, -40);
|
||||
dc.setColor(Graphics.COLOR_DK_RED, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(
|
||||
$.gX,
|
||||
$.gH * 0.75,
|
||||
$.gFontScore,
|
||||
"Cancel",
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ConfirmationDelegate extends WatchUi.InputDelegate {
|
||||
private var _callback as Method;
|
||||
|
||||
function initialize(callback as Method) {
|
||||
InputDelegate.initialize();
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
function onKey(keyEvent as KeyEvent) as Boolean {
|
||||
var key = keyEvent.getKey();
|
||||
|
||||
if (key == WatchUi.KEY_ENTER) {
|
||||
_callback.invoke(true); // Invoke original action
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == WatchUi.KEY_ESC) {
|
||||
_callback.invoke(false); // Cancelled
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user