//
//  WatchControlView.swift
//  Werkout_watch Watch App
//
//  Created by Trey Tartt on 7/8/23.
//

import SwiftUI

struct WatchControlView: View {
    @StateObject var vm = WatchMainViewModel.shared
    @StateObject var watchWorkout = WatchWorkout.shared
    
    var body: some View {
        HStack {
            VStack {
                Button(action: {
                    vm.completeWorkout()
                }, label: {
                    Image(systemName: "stop.circle")
                        .font(.title)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                })
                .buttonStyle(BorderedButtonStyle(tint: .red))
                
                Button(action: {
                    vm.restartExercise()
                }, label: {
                    Image(systemName: "arrow.counterclockwise.circle")
                        .font(.title)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                })
                .buttonStyle(BorderedButtonStyle(tint: .yellow))
                
                Button(action: {
                    vm.previousExercise()
                }, label: {
                    Image(systemName: "arrow.backward")
                        .font(.title)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                })
                .buttonStyle(BorderedButtonStyle(tint: .blue))
            }
            VStack {
                Button(action: {
                    vm.pauseWorkout()
                }, label: {
                    if watchWorkout.isPaused {
                        Image(systemName: "play")
                            .font(.title)
                            .frame(maxWidth: .infinity, maxHeight: .infinity)
                    } else {
                        Image(systemName: "pause")
                            .font(.title)
                            .frame(maxWidth: .infinity, maxHeight: .infinity)
                    }
                })
                .buttonStyle(BorderedButtonStyle(tint: .blue))
                
                Button(action: {
                    vm.nextExercise()
                }, label: {
                    Image(systemName: "arrow.forward")
                        .font(.title)
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                })
                .buttonStyle(BorderedButtonStyle(tint: .green))
            }
        }
    }
}

struct WatchControlView_Previews: PreviewProvider {
    static var previews: some View {
        WatchControlView(vm: WatchMainViewModel())
    }
}
