summaryrefslogtreecommitdiff
path: root/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'source/ui')
-rw-r--r--source/ui/HomeDelegate.mc16
-rw-r--r--source/ui/HomeView.mc42
2 files changed, 58 insertions, 0 deletions
diff --git a/source/ui/HomeDelegate.mc b/source/ui/HomeDelegate.mc
new file mode 100644
index 0000000..fe23ae6
--- /dev/null
+++ b/source/ui/HomeDelegate.mc
@@ -0,0 +1,16 @@
+// Author: cirakg & claude ai
+// Summary: Input handling for the home screen.
+//
+// HomeDelegate: input handling for the home screen.
+//
+// M0 has no actions yet. Inheriting BehaviorDelegate keeps the default
+// behaviours, so BACK (button or swipe) leaves the app on every device.
+
+import Toybox.WatchUi;
+
+class HomeDelegate extends WatchUi.BehaviorDelegate {
+
+ function initialize() {
+ BehaviorDelegate.initialize();
+ }
+}
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();
+ }
+ }
+}