Commit Graph

12 Commits

Author SHA1 Message Date
Jonas Bark
c81b51fcfd refactor(ios): extract shared GearSnapshot + add GearReadoutView for PiP
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 18:19:46 +02:00
Jonas Bark
221f4da1fe overlay/ios: put stop button in shared bottom row so it's actually visible
Previously the close button only lived in the expanded Dynamic Island's
trailing region — invisible on the lock-screen banner and only revealed
on long-press for the island. Move it into `bottomRow`, which is shared
by both surfaces, so the user sees the button in the default lock-screen
view and the expanded island without any interaction.

The Dynamic Island trailing region goes back to showing the mode pill.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 09:50:55 +02:00
Jonas Bark
1b91996fe1 overlay/ios: use BikeControl app icon in Dynamic Island
Replaces the SF Symbol "gear" (compactLeading) and "bicycle" (lock
screen / no-controls primary row) with the actual app icon.

Added an Assets.xcassets to the TrainerActivity widget extension
(the Runner's catalog isn't visible to the extension target) with
AppIcon@2x.png (120×120) and AppIcon@3x.png (180×180) copied from
the main app's AppIcon set. Referenced as `Image("AppIcon")` with
`.resizable().scaledToFit()` and a rounded-rect clip to match
iOS's standard app-icon shape.

The PBXFileSystemSynchronizedRootGroup membership for the
TrainerActivity folder auto-includes the new asset catalog in the
extension target — no project.pbxproj edits needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 09:47:09 +02:00
Jonas Bark
9648e5e604 overlay/ios: add Dynamic Island stop button that disconnects all devices
Replaces the trailing mode pill in the Dynamic Island expanded
region (which was redundant — the bottom row already shows the
SIM/ERG pill) with an `xmark.circle.fill` button.

Tapping the button:
1. Fires a new `StopRideIntent` App Intent.
2. That intent posts a Darwin notification
   `de.jonasbark.swiftcontrol.overlay.action.stop`.
3. `AppDelegate.swift`'s observer forwards `action: 'stop'` over
   the `bike_control/overlay_actions_ios` MethodChannel.
4. `IosOverlayController._stopRide`:
     - `core.connection.disconnectAll()`
     - `core.connection.stop()`
     - `core.settings.setOverlayEnabled(false)` so Navigation's
       auto-show doesn't immediately re-open the activity on the
       next BLE reconnect.
     - `hide()` ends the Live Activity.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 09:42:56 +02:00
Jonas Bark
b668350226 fix dynamic island 2026-05-11 14:13:19 +02:00
Jonas Bark
5e5bbfb4e7 ios: align Live Activity layout with new compact 2-row design
The Flutter overlay was redesigned: row 1 is the big mode-aware primary
(gear N/M in SIM, target W in ERG), row 2 has the SIM/ERG pill plus
opted-in metrics (power · cadence · ×ratio in SIM). Mirror that shape
in the iOS Widget Extension:

- Lock Screen / banner: bicycle SF Symbol on the left, big primary
  centered, mode pill + metrics on row 2.
- Dynamic Island expanded: leading = primary, trailing = mode pill,
  bottom = metrics row.
- Compact-trailing: '14/24' in SIM, '<target>W' in ERG.
- Minimal: gear number or watts target.

Centralised reads into a TrainerSnapshot helper so the lock-screen view
and dynamic-island regions can't drift apart. iOS Live Activities are
display-only; the +/- controls field has no analogue here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 07:56:24 +02:00
Jonas Bark
a1d1b72e5a ios: drop stray files from extension's filesystem-synchronized group
Xcode 16's PBXFileSystemSynchronizedRootGroup pulls every file in the
ios/TrainerActivity/ folder into the TrainerActivityExtension target by
default (Info.plist is the only membership exception). The leftover
TrainerActivity.entitlements (the actual one is ios/TrainerActivityExtension.entitlements)
and README.md from initial setup were getting bundled into the extension,
which may have confused the build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 15:39:27 +02:00
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
c847a10ed1 some fixes 2026-05-09 10:26:52 +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