aboutsummaryrefslogtreecommitdiff
path: root/source/ui/GlanceView.mc
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-19 22:28:09 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-19 22:28:09 +0200
commit35042ff04ffc50e55ff59a385849442be4429d6b (patch)
tree3c142dd9bfb995b7aacdf39128e591dd3f9370de /source/ui/GlanceView.mc
parent871aba901501302586895d266fe4569665d9fe70 (diff)
feat(ui): add the list, OTP detail, PIN entry, menu, info screens and glance
List with live codes and countdowns, adaptive rows and lazy headers; OTP detail with ring or bar, next code and HOTP next; PIN keypad or button selector with create, unlock, change, lockout display and pending promotion; native menu; glance with the entry count; self-test after the first frame; option properties with defaults. Codes are computed one per timer event, apart from drawing, for the watchdog. A UI-test build (uitest.jungle) starts with fake entries, PIN 123456 and a frozen clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'source/ui/GlanceView.mc')
-rw-r--r--source/ui/GlanceView.mc37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/ui/GlanceView.mc b/source/ui/GlanceView.mc
new file mode 100644
index 0000000..a7207ce
--- /dev/null
+++ b/source/ui/GlanceView.mc
@@ -0,0 +1,37 @@
+// Author: cirakg & claude ai
+// Summary: The glance (widget-list preview): app name and number of entries.
+//
+// Glances run with very little memory, so this reads only the entry index
+// from storage and opens no vault and no keys. The opt-in favourite code
+// (README 13.1) comes with M8.
+
+import Toybox.Application;
+import Toybox.Graphics;
+import Toybox.Lang;
+import Toybox.WatchUi;
+
+(:glance)
+class OtpGlanceView extends WatchUi.GlanceView {
+
+ function initialize() {
+ GlanceView.initialize();
+ }
+
+ function onUpdate(dc as Graphics.Dc) as Void {
+ var count = 0;
+ var meta = Application.Storage.getValue("m");
+ if (meta instanceof Dictionary) {
+ var ids = meta["ids"];
+ if (ids instanceof Array) {
+ count = ids.size();
+ }
+ }
+ var h = dc.getHeight();
+ dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
+ dc.drawText(0, h / 2 - dc.getFontHeight(Graphics.FONT_GLANCE), Graphics.FONT_GLANCE, "OTP WALLET", Graphics.TEXT_JUSTIFY_LEFT);
+ dc.setColor(Graphics.COLOR_LT_GRAY, Graphics.COLOR_TRANSPARENT);
+ dc.drawText(0, h / 2, Graphics.FONT_GLANCE, count == 1 ? "1 entry" : count + " entries", Graphics.TEXT_JUSTIFY_LEFT);
+ // The simulator starts in the glance; launch scripts open the app from it.
+ Diag.shown("glance");
+ }
+}