aboutsummaryrefslogtreecommitdiff
path: root/mobile/mobile.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-03 23:59:50 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-03 23:59:50 +0200
commit1106568c52265ea3076b9d3f1943c052c83a2a89 (patch)
treee969fca7657b7eeb5d612fc6f966c7f03051aa2e /mobile/mobile.go
parent27ceffcb90c0716179342109163c559d492a8abc (diff)
downloadlectio-1106568c52265ea3076b9d3f1943c052c83a2a89.tar.gz
lectio-1106568c52265ea3076b9d3f1943c052c83a2a89.zip
mobile: add PartLabels so the app stops hardcoding part IDs
Diffstat (limited to 'mobile/mobile.go')
-rw-r--r--mobile/mobile.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/mobile/mobile.go b/mobile/mobile.go
index e79e748..d863463 100644
--- a/mobile/mobile.go
+++ b/mobile/mobile.go
@@ -184,6 +184,37 @@ func Days(start string, count int, form, lang string) string {
return string(b)
}
+// partLabel is one section's machine ID and its human label.
+type partLabel struct {
+ Part string `json:"part"`
+ Label string `json:"label"`
+}
+
+// PartLabels returns the form's section IDs and their labels in lang, in display
+// order, as a JSON array. The app builds its reading filters from this instead
+// of hardcoding part IDs -- which is how it came to ship seven 1962 checkboxes
+// the engine never emits.
+//
+// An array, not an object: JSON object key order is not guaranteed and the app
+// renders these in order.
+func PartLabels(form, lang string) string {
+ ids := readings.PartIDs(lectByForm(form))
+ ui := i18n.Get(lang)
+ out := make([]partLabel, 0, len(ids))
+ for _, id := range ids {
+ label := ui.PartLabel[id]
+ if label == "" {
+ label = id
+ }
+ out = append(out, partLabel{Part: id, Label: label})
+ }
+ b, err := json.Marshal(out)
+ if err != nil {
+ return "[]"
+ }
+ return string(b)
+}
+
// Ping is a trivial JNI smoke test: it returns "pong" so the app can confirm the
// native engine loaded before issuing a real query.
func Ping() string { return "pong" }