//
//  ContentView.swift
//  Workouts Watch App
//
//  Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//

import SwiftUI

struct ContentView: View {
    @Environment(WatchConnectivityBridge.self) private var bridge

    var body: some View {
        ActiveWorkoutGateView()
            // The iPhone started driving a run we're not already in — follow it live here.
            .fullScreenCover(isPresented: Binding(
                get: { bridge.presentable != nil },
                set: { presenting in if !presenting { bridge.muteLive() } }
            )) {
                if let frame = bridge.presentable {
                    // Re-key on the followed log so a flow-mode auto-advance (the driver
                    // moving to the next exercise) rebuilds the mirror for the new exercise
                    // instead of leaving a stale one pinned to the previous log.
                    LiveRunCoverView(frame: frame) { bridge.muteLive() }
                        .id(frame.logID)
                }
            }
    }
}
