From d537f4e154a40075405b0ab2fed14fbe2eeaac81 Mon Sep 17 00:00:00 2001 From: cirakg Date: Tue, 20 Oct 2026 01:51:05 +0200 Subject: 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 --- source/settings/Results.mc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 source/settings/Results.mc (limited to 'source/settings/Results.mc') 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) as Void { + var kept = lines.size() > MAX_LINES ? lines.slice(0, MAX_LINES) as Array : lines; + Application.Storage.setValue(KEY, {"l" => kept, "u" => true} as Dictionary); + } + + // The stored lines, or a short explanation when there are none. + function lines() as Array { + var stored = Application.Storage.getValue(KEY); + if (stored instanceof Dictionary && stored["l"] instanceof Array) { + return stored["l"] as Array; + } + 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); + } + } + + function isTrue(value as Application.Storage.ValueType) as Boolean { + return value instanceof Boolean && value; + } +} -- cgit v1.2.3