Commit Graph

4 Commits

Author SHA1 Message Date
Jonas Bark
f098f5c7bf ios: align extension Swift with the working live_activities example
Two structural fixes after diffing against the package's working example:
- Revert ContentState to empty. The plugin's createActivity calls a
  ContentState() constructor with no args from the example pattern; the
  appGroupId field was a red herring from the plugin's internal type.
- Switch the widget's @available marker from iOS 16.1 to
  iOSApplicationExtension 16.1, the correct platform key for an app
  extension target. iOS 16.1 was being honored at compile time but the
  WidgetKit registration uses the extension-specific availability scope.
- Inline the field reads inside the widget closures (matches the example
  layout) instead of routing through a helper struct.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 15:37:28 +02:00
Jonas Bark
9b7d6a7b4a ios: add appGroupId to ContentState to match live_activities plugin schema
The plugin's internal LiveActivitiesAppAttributes.ContentState declares
'var appGroupId: String' and constructs Activity requests with that
field populated. Our widget declared an empty ContentState, so ActivityKit
rejected every launch with ActivityInput error 0 (malformedAttributes).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 15:24:32 +02:00
Jonas Bark
3711d82b7a ios: rewrite Live Activity widget for live_activities package's contract
The package always launches Activity<LiveActivitiesAppAttributes> internally
and writes payload fields to the App Group's UserDefaults keyed by
"<id>_<fieldName>". Our custom TrainerActivityAttributes was never matched
by the system (ActivityInput error 0).

- Replace TrainerActivityAttributes with the package-required
  LiveActivitiesAppAttributes (empty ContentState + UUID id + prefixedKey
  helper extension).
- Rewrite TrainerActivity widget to read all fields from
  UserDefaults(suiteName: "group.de.jonasbark.swiftcontrol.overlay") via
  attributes.prefixedKey(...).
- Wrap the widget in a WidgetBundle gated on iOS 16.1 so the @main entry
  point compiles on older deployment targets too.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 10:48:36 +02:00
Jonas Bark
447af0ebf4 ios: add TrainerActivity Widget Extension (Lock Screen + Dynamic Island)
Adds all source files for the TrainerActivity WidgetKit extension:
TrainerActivity.swift (@main, Lock Screen banner + Dynamic Island views),
TrainerActivityAttributes.swift (ActivityAttributes struct with gear,
mode, power, cadence, and erg-target fields), Info.plist, and
TrainerActivity.entitlements (App Group group.de.jonasbark.swiftcontrol.overlay).

A README documents the one-time manual Xcode steps required to wire the
target before flutter build ios will succeed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 09:20:45 +02:00