//
//  ContentView.swift
//  forShip
//
//  Created by Mamoru Sugita on 2023/10/13.
//

import SwiftUI

struct ContentView: View {
    @State var isLogin = true//ContentView.LoginCheck()
    @EnvironmentObject private var sceneDelegate: SceneDelegate
    var selectedTabModel = SelectedTabModel()

    var body: some View {

        MainTabView()
            .environmentObject(selectedTabModel)
            .onAppear(){
                if isLogin{
                    guard sceneDelegate.tabWindow == nil else{ return }
                    sceneDelegate.addTabBar(selectedTabModel)
                    selectedTabModel.activeTab = .task
                }
            }
            .fullScreenCover(isPresented: .constant(!isLogin), onDismiss: {
                guard sceneDelegate.tabWindow == nil else{ return }
                sceneDelegate.addTabBar(selectedTabModel)
                selectedTabModel.activeTab = .task
            }, content: {
                LoginView(isLogin: $isLogin)
            })
    }
}

#Preview {
    ContentView()
        .environmentObject(SceneDelegate())
}
