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

import SwiftUI

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

    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())
}
