aboutsummaryrefslogtreecommitdiff
path: root/source/settings/Results.mc
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-20 01:51:05 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-20 01:51:05 +0200
commitd537f4e154a40075405b0ab2fed14fbe2eeaac81 (patch)
treef1fb9b148871901dda96fca11401d6f4d0ee1d59 /source/settings/Results.mc
parent40d9a1d5c3e85486aea964c1446402a3be6ec05a (diff)
feat(settings): apply the Import form from the phone and show results
Import group in the app settings; the processor runs after the first frame and on settings changes, clears the fields, writes the status, remembers form hashes and opens the results screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'source/settings/Results.mc')
-rw-r--r--source/settings/Results.mc43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/settings/Results.mc b/source/settings/Results.mc
new file mode 100644
index 0000000..37c932f
--- /dev/null
+++ b/source/settings/Results.mc
@@ -0,0 +1,43 @@
+// Author: cirakg & claude ai
+// Summary: The latest settings results (README 10.3): kept in storage for the results screen, with an unseen flag for the list.
+
+import Toybox.Application;
+import Toybox.Lang;
+
+module Results {
+
+ const KEY = "res";
+ const MAX_LINES = 60;
+
+ // Replace the stored results with these lines (marked unseen).
+ function save(lines as Array<String>) as Void {
+ var kept = lines.size() > MAX_LINES ? lines.slice(0, MAX_LINES) as Array<String> : lines;
+ Application.Storage.setValue(KEY, {"l" => kept, "u" => true} as Dictionary<Application.Storage.KeyType, Application.Storage.ValueType>);
+ }
+
+ // The stored lines, or a short explanation when there are none.
+ function lines() as Array<String> {
+ var stored = Application.Storage.getValue(KEY);
+ if (stored instanceof Dictionary && stored["l"] instanceof Array) {
+ return stored["l"] as Array<String>;
+ }
+ return ["Nothing yet. Results appear here after you import or change entries in the phone settings."];
+ }
+
+ function unseen() as Boolean {
+ var stored = Application.Storage.getValue(KEY);
+ return stored instanceof Dictionary && isTrue(stored["u"]);
+ }
+
+ function markSeen() as Void {
+ var stored = Application.Storage.getValue(KEY);
+ if (stored instanceof Dictionary && isTrue(stored["u"])) {
+ stored["u"] = false;
+ Application.Storage.setValue(KEY, stored as Dictionary<Application.Storage.KeyType, Application.Storage.ValueType>);
+ }
+ }
+
+ function isTrue(value as Application.Storage.ValueType) as Boolean {
+ return value instanceof Boolean && value;
+ }
+}