//
//  SQProgressBar.swift
//  AlloVoisinsSwiftUI
//
//  Created by Victor on 17/10/2024.
//

import SwiftUI

struct SQProgressBar: View {
    var progress: Double // Valeur entre 0 et 1

    var body: some View {
        GeometryReader { geometry in
            ZStack(alignment: .leading) {
                Rectangle()
                    .foregroundColor(Color.sqNeutral(20))
                    .frame(width: geometry.size.width, height: 12)
                    .cornerRadius(50)

                Rectangle()
                    .foregroundColor(Color.sqNeutral(60)) // Vous pouvez changer la couleur ici
                    .frame(width: min(CGFloat(self.progress) * geometry.size.width, geometry.size.width), height: 12)
                    .cornerRadius(50)
            }
        }
        .frame(height: 12)
        .frame(maxWidth: .infinity, alignment: .topLeading)
        .background(Color.sqNeutral(20))
        .cornerRadius(12)
    }
}

#Preview {
    SQProgressBar(progress: 0.2)
        .padding()
}
