//
//  RegisterView.swift
//  AcaMate
//
//  Created by TAnine on 2/20/25.
//

import SwiftUI

struct RegisterView: View {
    @EnvironmentObject var appVM: AppViewModel
    @StateObject private var topVM = TopViewModel()
    
    @State private var scrollOffset: CGPoint = .zero
    
    let type: SNSLoginType
    let snsID: String
    
    @State private var selectDate: Date = {
        let calendar = Calendar.current
        return calendar.date(byAdding: .year, value: -12, to: Date()) ?? Date()
    }()
    
    var body: some View {
        // MARK: TO-DO
        // 회원가입 뷰 만들기
        // 이름, 번호, 이메일, 주소, 생년월일
        
        
        VStack(spacing: 0) {
            TopView(topVM: topVM)
            
            OffsetObservableScrollView(showsIndicators: false, scrollOffset: $scrollOffset) { proxy in
                
                DatePicker("생년월일 입력", selection: $selectDate, displayedComponents: [.date])
                    .datePickerStyle(.compact)
                    .environment(\.locale, Locale(identifier: "ko_KR"))
                    .font(.nps(size: 16))
                    .padding()
                
                
            }
            .frame(maxWidth: .infinity, maxHeight: .infinity)
        }
        .onAppear {
            topVM.titleName = "회원가입"
            topVM.setLeftBtn(Image(.Icon.left), size: CGPoint(x: 40, y: 40), action: leftAct)
            topVM.setRightBtn(size: CGPoint(x: 40, y: 40), action: rightAct)
            
            
        }
    }
    
    func leftAct() {
        printLog("왼쪽 버튼 클릭")
        appVM.naviState.set(act: .POP)
    }
    func rightAct() {
        printLog("오른쪽 버튼 클릭")
    }
}

