//
//  SelectDatePicker.swift
//  SodaLive
//
//  Created by klaus on 2024/01/10.
//

import SwiftUI

struct SelectDatePicker: View {
    
    @Binding var selectedDate: Date
    @Binding var isShowing: Bool
    
    var body: some View {
        GeometryReader { proxy in
            ZStack {
                Color
                    .black
                    .opacity(0.5)
                    .edgesIgnoringSafeArea(.all)
                
                VStack(spacing: 0) {
                    DatePicker("", selection: $selectedDate, in: Date()..., displayedComponents: .date)
                        .datePickerStyle(WheelDatePickerStyle())
                        .labelsHidden()
                        .environment(\.locale, Locale.init(identifier: "ko"))
                        .frame(width: proxy.size.width)
                    
                    Button(action: { self.isShowing = false }) {
                        Text("확인")
                            .font(.system(size: 16))
                            .foregroundColor(Color(hex: "eeeeee"))
                            .padding(.vertical, 10)
                            .frame(width: proxy.size.width - 53.4)
                    }
                }
                .background(Color(hex: "222222"))
                .cornerRadius(6.7)
            }
            .frame(width: proxy.size.width)
        }
    }
}

struct SelectDatePicker_Previews: PreviewProvider {
    static var previews: some View {
        SelectDatePicker(
            selectedDate: .constant(Date()),
            isShowing: .constant(true)
        )
    }
}
