diff options
Diffstat (limited to 'source/ui/GlanceView.mc')
| -rw-r--r-- | source/ui/GlanceView.mc | 37 |
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"); + } +} |
