summaryrefslogtreecommitdiff
path: root/source/ui/HomeView.mc
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-18 21:10:37 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-18 21:10:37 +0200
commit773df56883b9961b607a1994920f5ef5299423b8 (patch)
treee813e8f975e3cfa7a992222e5bf63ef615469916 /source/ui/HomeView.mc
parent2292bf700d28ade39cf2d64b45509e6db21034bc (diff)
feat(app): add minimal watch app with smoke test and per-size icons
The M0 placeholder app: AppBase entry point, home screen with name and version, debug-only diagnostics (start-up time, memory) and a unit test that runs in the headless simulator. Builds with strict type checking and zero warnings for all 72 products; icons.jungle gives every product a launcher icon of its exact size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'source/ui/HomeView.mc')
-rw-r--r--source/ui/HomeView.mc42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/ui/HomeView.mc b/source/ui/HomeView.mc
new file mode 100644
index 0000000..f73c783
--- /dev/null
+++ b/source/ui/HomeView.mc
@@ -0,0 +1,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();
+ }
+ }
+}