//
//  MainTabView.swift
//  Feels (iOS)
//
//  Created by Trey Tartt on 2/18/22.
//

import SwiftUI

struct MainTabView: View {
    @AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
    
    let onboardingData = OnboardingDataDataManager.shared.savedOnboardingData
    
    var body: some View {
        TabView {
            HomeViewTwo()
                .tabItem {
                    Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
                }
            
            HomeView()
                .tabItem {
                    Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
                }
            
            FilterView()
                .tabItem {
                    Label(String(localized: "content_view_tab_filter"), systemImage: "calendar.circle")
                }
            
            SharingListView()
                .tabItem {
                    Label(String(localized: "content_view_tab_share"), systemImage: "square.and.arrow.up")
                }
        }.sheet(isPresented: $needsOnboarding, onDismiss: {
            
        }, content: {
            OnboardingMain(onboardingData: onboardingData,
                           updateBoardingDataClosure: { onboardingData in
                needsOnboarding = false
                OnboardingDataDataManager.shared.updateOnboardingData(onboardingData: onboardingData)
            })
        })
    }
}

struct MainTabView_Previews: PreviewProvider {
    static var previews: some View {
        MainTabView()
    }
}
