//
//  OnboardingMain.swift
//  Feels (iOS)
//
//  Created by Trey Tartt on 1/20/22.
//

import SwiftUI

struct OnboardingMain: View {
    @Environment(\.presentationMode) var presentationMode
    @State var onboardingData: OnboardingData
    
    let updateBoardingDataClosure: ((OnboardingData) -> Void)
    
    var body: some View {
        TabView {
            OnboardingTime(onboardingData: onboardingData)
            
            OnboardingDay(onboardingData: onboardingData)
            
            OnboardingTitle(onboardingData: onboardingData)
            
            OnboardingWrapup(onboardingData: onboardingData, completionClosure: { _ in
                updateBoardingDataClosure(onboardingData)
            })
        }
        .ignoresSafeArea()
        .tabViewStyle(.page)
        .onAppear {
            setupAppearance()
        }
        .interactiveDismissDisabled()
    }
    
    func setupAppearance() {
        UIPageControl.appearance().currentPageIndicatorTintColor = .white
        UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
    }
}

struct OnboardingMain_Previews: PreviewProvider {
    static var previews: some View {
        OnboardingMain(onboardingData: OnboardingData(),
                       updateBoardingDataClosure: { _ in
            
        })
    }
}
