//
//  RateWorkoutView.swift
//  Werkout_ios
//
//  Created by Trey Tartt on 6/18/24.
//

import SwiftUI

struct RateWorkoutView: View {
    @Binding var difficulty: Float
    
    var body: some View {
        VStack {
            Divider()
            
            HStack {
                Text("No Rate")
                    .foregroundColor(.black)
                Text("Easy")
                    .foregroundColor(.green)
                Spacer()
                Text("Death")
                    .foregroundColor(.red)
            }
            
            ZStack {
                LinearGradient(
                    gradient: Gradient(colors: [.black, .green, .red]),
                    startPoint: .leading,
                    endPoint: .trailing
                )
                .mask(Slider(value: $difficulty, in: 0...5, step: 1))
                
                // Dummy replicated slider, to allow sliding
                Slider(value: $difficulty, in: 0...5, step: 1)
                    .opacity(0.05) // Opacity is the trick here.
                    .accentColor(.clear)
            }
        }
    }
}

//#Preview {
//    RateWorkoutView()
//}
