//
//  ContentView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/09.
//

import SwiftUI

struct ContentView: View {
    @StateObject private var appState = AppState.shared
    
    var body: some View {
        ZStack {
            Color.black.ignoresSafeArea()
            
            MainView()
            
            switch appState.appStep {
            case .splash:
                SplashView()
                
            case .signUp:
                SignUpView()
                
            case .findPassword:
                FindPasswordView()
                
            case .textMessageDetail(let messageItem, let messageBox, let refresh):
                TextMessageDetailView(messageItem: messageItem, messageBox: messageBox, refresh: refresh)
                
            case .writeTextMessage(let userId, let nickname):
                TextMessageWriteView(replySenderId: userId, replySenderNickname: nickname)
                
            case .writeVoiceMessage(let userId, let nickname, let onRefresh):
                VoiceMessageWriteView(replySenderId: userId, replySenderNickname: nickname, onRefresh: onRefresh)
                
            case .settings:
                SettingsView()
                
            case .notices:
                NoticeListView()
                
            case .noticeDetail(let notice):
                NoticeDetailView(notice: notice)
                
            case .events:
                EventListView()
                
            case .eventDetail(let event):
                EventDetailView(event: event)
                
            case .terms:
                TermsView(isPrivacyPolicy: false)
                
            case .privacy:
                TermsView(isPrivacyPolicy: true)
                
            case .notificationSettings:
                NotificationSettingsView()
                
            case .signOut:
                SignOutView()
                
            case .canStatus(let refresh):
                CanStatusView(refresh: refresh)
                
            case .canCharge(let refresh, let afterCompletionToGoBack):
                CanChargeView(refresh: refresh, afterCompletionToGoBack: afterCompletionToGoBack)
                
            case .canPayment(let canProduct, let refresh, let afterCompletionToGoBack):
                CanPaymentView(canProduct: canProduct, refresh: refresh, afterCompletionToGoBack: afterCompletionToGoBack)
                
            case .canPgPayment(let canResponse, let refresh, let afterCompletionToGoBack):
                CanPgPaymentView(canResponse: canResponse, refresh: refresh, afterCompletionToGoBack: afterCompletionToGoBack)
                
            case .liveReservation:
                LiveReservationStatusView()
                
            case .liveReservationCancel(let reservationId):
                LiveReservationCancelView(reservationId: reservationId)
                
            default:
                EmptyView()
                    .frame(width: 0, height: 0, alignment: .topLeading)
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
