//
//  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()
            
            if appState.isChangeAdultContentVisible {
                EmptyView()
            } else {
                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 .contentViewSettings:
                ContentSettingsView()
                
            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)
                
            case .serviceCenter:
                ServiceCenterView()
                
            case .createContent:
                ContentCreateView()
                
            case .liveReservationComplete(let response):
                LiveReservationCompleteView(reservationCompleteData: response)
                
            case .creatorDetail(let userId):
                UserProfileView(userId: userId)
                
            case .followerList(let userId):
                FollowerListView(userId: userId)
                
            case .modifyContent(let contentId):
                ContentModifyView(contentId: contentId)
                
            case .contentListAll(let userId):
                ContentListView(userId: userId)
                
            case .contentDetail(let contentId):
                ContentDetailView(contentId: contentId)
                
            case .createLive(let timeSettingMode, let onSuccess):
                LiveRoomCreateView(
                    timeSettingMode: timeSettingMode,
                    onSuccess: onSuccess
                )
                
            case .liveNowAll(let onClickParticipant):
                LiveNowAllView(onClickParticipant: onClickParticipant)
                
            case .liveReservationAll(let onClickReservation, let onClickStart, let onClickCancel, let onTapCreateLive):
                LiveReservationAllView(
                    onClickReservation: onClickReservation,
                    onClickStart: onClickStart,
                    onClickCancel: onClickCancel,
                    onTapCreateLive: onTapCreateLive
                )
                
            case .modifyLive(let room):
                LiveRoomEditView(room: room)
                
            case .liveDetail(let roomId, let onClickParticipant, let onClickReservation, let onClickStart, let onClickCancel):
                LiveDetailView(
                    roomId: roomId,
                    onClickParticipant: onClickParticipant,
                    onClickReservation: onClickReservation,
                    onClickStart: onClickStart,
                    onClickCancel: onClickCancel
                )
                
            case .modifyPassword:
                ModifyPasswordView()
                
            case .changeNickname:
                NicknameUpdateView()
                
            case .profileUpdate(let refresh):
                ProfileUpdateView(refresh: refresh)
                
            case .followingList:
                FollowCreatorView()
                
            case .orderListAll:
                OrderListAllView()
                
            case .userProfileDonationAll(let userId):
                UserProfileDonationAllView(userId: userId)
                
            case .userProfileFanTalkAll(let userId):
                UserProfileFanTalkAllView(userId: userId)
                
            case .newContentAll:
                ContentNewAllView()
                
            case .curationAll(let title, let curationId):
                ContentCurationView(title: title, curationId: curationId)
                
            case .contentRankingAll:
                ContentRankingAllView()
                
            case .creatorCommunityAll(let creatorId):
                CreatorCommunityAllView(creatorId: creatorId)
                
            case .creatorCommunityWrite(let onSuccess):
                CreatorCommunityWriteView(onSuccess: onSuccess)
                
            case .creatorCommunityModify(let postId, let onSuccess):
                CreatorCommunityModifyView(postId: postId, onSuccess: onSuccess)
                
            case .canCoupon:
                CanCouponView()
                
            case .contentAllByTheme(let themeId):
                ContentAllByThemeView(themeId: themeId)
                
            case .seriesAll(let creatorId):
                SeriesListAllView(creatorId: creatorId)
                
            case .seriesDetail(let seriesId):
                SeriesDetailView(seriesId: seriesId)
                
            case .seriesContentAll(let seriesId, let seriesTitle):
                SeriesContentAllView(seriesId: seriesId, seriesTitle: seriesTitle)
                
            case .tempCanPayment(let orderType, let contentId, let title, let can):
                CanPaymentTempView(orderType: orderType, contentId: contentId, title: title, can: can)
            
            case .blockList:
                BlockMemberListView()
                
            default:
                EmptyView()
                    .frame(width: 0, height: 0, alignment: .topLeading)
            }
        }
    }
}

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