blob: f73c7839aebb29cf3e9c3e6cbf8b2723ee18ad9a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Author: cirakg & claude ai
// Summary: M0 placeholder home screen showing the app name and version.
//
// HomeView: the M0 placeholder home screen. It draws the app name and version
// in the centre of the screen. Milestone M4 replaces it with the entry list.
//
// Performance note: everything that allocates (loading the name string,
// building the version text) happens once in initialize(), not in onUpdate().
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.WatchUi;
class HomeView extends WatchUi.View {
private var _title as String;
private var _version as String;
// Set after the first complete draw, so start-up diagnostics run once.
private var _firstFrameDone as Boolean = false;
function initialize() {
View.initialize();
_title = WatchUi.loadResource(Rez.Strings.AppName) as String;
_version = "v" + AppInfo.VERSION;
}
function onUpdate(dc as Graphics.Dc) as Void {
var centerX = dc.getWidth() / 2;
var centerY = dc.getHeight() / 2;
var justify = Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER;
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
dc.clear();
dc.drawText(centerX, centerY, Graphics.FONT_MEDIUM, _title, justify);
dc.drawText(centerX, centerY + dc.getFontHeight(Graphics.FONT_MEDIUM), Graphics.FONT_XTINY, _version, justify);
if (!_firstFrameDone) {
_firstFrameDone = true;
Diag.firstFrame();
}
}
}
|