//
//  CreateViewRepsWeightView.swift
//  Werkout_ios
//
//  Created by Trey Tartt on 6/18/23.
//

import SwiftUI

struct CreateExerciseActionsView: View {
    @ObservedObject var workoutExercise: CreateWorkoutExercise
    var superset: CreateWorkoutSuperSet
    var viewModel: WorkoutViewModel
    
    var body: some View {
        VStack {
            if workoutExercise.exercise.isReps {
                HStack {
                    VStack {
                        HStack {
                            Text("Reps: ")
                            Text("\(workoutExercise.reps)")
                        }
                        Stepper("", onIncrement: {
                            workoutExercise.increaseReps()
                        }, onDecrement: {
                            workoutExercise.decreaseReps()
                        })
                        .labelsHidden()
                    }
                    .frame(maxWidth: .infinity)
                    Divider()
                    VStack{
                        HStack {
                            Text("Weight: ")
                            Text("\(workoutExercise.weight)")
                        }
                        Stepper("", onIncrement: {
                            workoutExercise.increaseWeight()
                        }, onDecrement: {
                            workoutExercise.decreaseWeight()
                        })
                        .labelsHidden()
                    }
                    .frame(maxWidth: .infinity)
                }
            } else if workoutExercise.exercise.isDuration {
                VStack{
                    HStack {
                        Text("Duration: ")
                        Text("\(workoutExercise.duration)")
                    }
                    Stepper("", onIncrement: {
                        workoutExercise.increaseDuration()
                    }, onDecrement: {
                        workoutExercise.decreaseDuration()
                    })
                }
            }
            
            HStack {
                Spacer()
                Button(action: {
                }) {
                    Image(systemName: "video.fill")
                }
                .frame(width: 88, height: 44)
                .foregroundColor(.white)
                .background(.blue)
                .cornerRadius(10)
                
                Spacer()
                
                Divider()
                
                Spacer()
                
                Button(action: {
                    superset.deleteExerciseForChosenSuperset(exercise: workoutExercise)
                    viewModel.objectWillChange.send()
                }) {
                    Image(systemName: "trash.fill")
                }
                .frame(width: 88, height: 44)
                .foregroundColor(.white)
                .background(.red)
                .cornerRadius(10)
                Spacer()
            }
            
            Divider()
                .background(.blue)
        }
    }
}

//struct CreateViewRepsWeightView_Previews: PreviewProvider {
//    static var previews: some View {
//        CreateViewRepsWeightView()
//    }
//}
