Phase 3: event creation flow (GPS + success / error)
GpsService runs a single-shot position request with a hard timeout and early-exit when Config.GPS_TARGET_ACCURACY_M is reached. LoadingView renders a circular progress bar around the edge plus the "Standort wird bestimmt" prompt; on callback it persists a new Event via EventStore.add and transitions to SuccessView (green checkmark, short vibration, auto-close) or ErrorView (red alert, 3× vibration, German message, longer hold). TextUtils extracts the shared multi-line centered text rendering so MenuView, LoadingView and ErrorView all render wrapped German text consistently. Positioning permission added to manifest. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d3494acc0d
commit
025d3007db
9 changed files with 332 additions and 17 deletions
46
source/TextUtils.mc
Normal file
46
source/TextUtils.mc
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import Toybox.Graphics;
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
|
||||
// Text layout helpers. CIQ's drawText does not wrap, so callers split
|
||||
// a string by a separator and hand us an Array<String> which we
|
||||
// render vertically centered around (cx, cy).
|
||||
module TextUtils {
|
||||
|
||||
const LINE_SEPARATOR = "|";
|
||||
|
||||
function splitLines(text as String) as Array<String> {
|
||||
var result = [] as Array<String>;
|
||||
var current = "";
|
||||
for (var i = 0; i < text.length(); i++) {
|
||||
var c = text.substring(i, i + 1);
|
||||
if (c.equals(LINE_SEPARATOR)) {
|
||||
result.add(current);
|
||||
current = "";
|
||||
} else {
|
||||
current += c;
|
||||
}
|
||||
}
|
||||
result.add(current);
|
||||
return result;
|
||||
}
|
||||
|
||||
function drawCentered(dc as Dc, lines as Array<String>,
|
||||
cx as Number, cy as Number, font as Graphics.FontType) as Void {
|
||||
var lineHeight = dc.getFontHeight(font);
|
||||
var totalHeight = lines.size() * lineHeight;
|
||||
var startY = cy - totalHeight / 2 + lineHeight / 2;
|
||||
for (var j = 0; j < lines.size(); j++) {
|
||||
dc.drawText(cx, startY + j * lineHeight, font, lines[j],
|
||||
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
}
|
||||
}
|
||||
|
||||
// Convenience: load a string resource and split + draw in one call.
|
||||
function drawResourceCentered(dc as Dc, resourceId as ResourceId,
|
||||
cx as Number, cy as Number,
|
||||
font as Graphics.FontType) as Void {
|
||||
var text = WatchUi.loadResource(resourceId) as String;
|
||||
drawCentered(dc, splitLines(text), cx, cy, font);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue