mirror of
https://github.com/XAMPPRocky/tokei.git
synced 2026-05-28 00:20:57 +02:00
69 lines
2.0 KiB
Mason
69 lines
2.0 KiB
Mason
// 69 lines 41 code 18 comments 10 blanks
|
|
// Slightly modified template from the "Garmin.monkey-c" VS Code extension.
|
|
import Toybox.Application;
|
|
import Toybox.Graphics;
|
|
import Toybox.Lang;
|
|
import Toybox.System;
|
|
import Toybox.WatchUi;
|
|
|
|
class WatchFaceView extends WatchUi.WatchFace {
|
|
|
|
function initialize() {
|
|
WatchFace.initialize();
|
|
}
|
|
|
|
// Load your resources here
|
|
function onLayout(dc as Dc) as Void {
|
|
setLayout(Rez.Layouts.WatchFace(dc));
|
|
}
|
|
|
|
/*
|
|
Called when this View is brought to the foreground. Restore
|
|
the state of this View and prepare it to be shown. This includes
|
|
loading resources into memory.
|
|
*/
|
|
function onShow() as Void {
|
|
}
|
|
|
|
// Update the view
|
|
function onUpdate(dc as Dc) as Void {
|
|
// Get the current time and format it correctly
|
|
var timeFormat = "$1$:$2$";
|
|
var clockTime = System.getClockTime();
|
|
var hours = clockTime.hour;
|
|
if (!System.getDeviceSettings().is24Hour) {
|
|
if (hours > 12) {
|
|
hours = hours - 12;
|
|
}
|
|
} else {
|
|
if (getApp().getProperty("UseMilitaryFormat")) {
|
|
timeFormat = "$1$$2$";
|
|
hours = hours.format("%02d");
|
|
}
|
|
}
|
|
var timeString = Lang.format(timeFormat, [hours, clockTime.min.format("%02d")]);
|
|
|
|
// Update the view
|
|
var view = View.findDrawableById("TimeLabel") as Text;
|
|
view.setColor(getApp().getProperty("ForegroundColor") as Number);
|
|
view.setText(timeString);
|
|
|
|
View.onUpdate(dc); // Call the parent onUpdate function to redraw the layout
|
|
}
|
|
|
|
/*
|
|
Called when this View is removed from the screen. Save the
|
|
state of this View here. This includes freeing resources from
|
|
memory.
|
|
*/
|
|
function onHide() as Void {
|
|
}
|
|
|
|
// The user has just looked at their watch. Timers and animations may be started here.
|
|
function onExitSleep() as Void {
|
|
}
|
|
|
|
// Terminate any active timers and prepare for slow updates.
|
|
function onEnterSleep() as Void {
|
|
}
|
|
} |