312 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			312 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  ContentView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/08/09.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct ContentView: View {
 | 
						|
    @ObservedObject var canPgPaymentViewModel: CanPgPaymentViewModel
 | 
						|
    @StateObject private var appState = AppState.shared
 | 
						|
    
 | 
						|
    @State private var isShowDialog = false
 | 
						|
    @State private var message = ""
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        ZStack {
 | 
						|
            Color.black.ignoresSafeArea()
 | 
						|
            
 | 
						|
            if appState.isChangeAdultContentVisible {
 | 
						|
                EmptyView()
 | 
						|
            } else {
 | 
						|
                HomeView()
 | 
						|
            }
 | 
						|
            
 | 
						|
            switch appState.appStep {
 | 
						|
            case .splash:
 | 
						|
                SplashView()
 | 
						|
                
 | 
						|
            case .login:
 | 
						|
                LoginView()
 | 
						|
                
 | 
						|
            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)
 | 
						|
                    .environmentObject(canPgPaymentViewModel)
 | 
						|
                
 | 
						|
            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(let isFree):
 | 
						|
                ContentNewAllView(isFree: isFree)
 | 
						|
                
 | 
						|
            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(let refresh):
 | 
						|
                CanCouponView(refresh: refresh)
 | 
						|
                
 | 
						|
            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()
 | 
						|
                
 | 
						|
            case .myBox(let currentTab):
 | 
						|
                ContentBoxView(initCurrentTab: currentTab)
 | 
						|
                
 | 
						|
            case .auditionDetail(let auditionId):
 | 
						|
                AuditionDetailView(auditionId: auditionId)
 | 
						|
                
 | 
						|
            case .auditionRoleDetail(let roleId, let auditionTitle):
 | 
						|
                AuditionRoleDetailView(
 | 
						|
                    roleId: roleId,
 | 
						|
                    auditionTitle: auditionTitle
 | 
						|
                )
 | 
						|
                
 | 
						|
            case .search:
 | 
						|
                SearchView()
 | 
						|
                
 | 
						|
            case .contentMain(let startTab):
 | 
						|
                ContentMainViewV2(selectedTab: startTab)
 | 
						|
                
 | 
						|
            case .completedSeriesAll:
 | 
						|
                CompletedSeriesView()
 | 
						|
                
 | 
						|
            case .newAlarmContentAll:
 | 
						|
                ContentMainAlarmAllView()
 | 
						|
                
 | 
						|
            case .newAsmrContentAll:
 | 
						|
                ContentMainAsmrAllView()
 | 
						|
                
 | 
						|
            case .newReplayContentAll:
 | 
						|
                ContentMainReplayAllView()
 | 
						|
                
 | 
						|
            case .introduceCreatorAll:
 | 
						|
                ContentMainIntroduceCreatorAllView()
 | 
						|
                
 | 
						|
            case .message:
 | 
						|
                MessageView()
 | 
						|
                
 | 
						|
            case .pointStatus(let refresh):
 | 
						|
                PointStatusView(refresh: refresh)
 | 
						|
                
 | 
						|
            case .audition:
 | 
						|
                AuditionView()
 | 
						|
                
 | 
						|
            case .characterDetail(let characterId):
 | 
						|
                CharacterDetailView(characterId: characterId)
 | 
						|
                
 | 
						|
            case .chatRoom(let id):
 | 
						|
                ChatRoomView(roomId: id)
 | 
						|
                
 | 
						|
            case .newCharacterAll:
 | 
						|
                NewCharacterListView()
 | 
						|
                
 | 
						|
            case .originalWorkDetail(let originalId):
 | 
						|
                OriginalWorkDetailView(originalId: originalId)
 | 
						|
                
 | 
						|
            default:
 | 
						|
                EmptyView()
 | 
						|
                    .frame(width: 0, height: 0, alignment: .topLeading)
 | 
						|
            }
 | 
						|
            
 | 
						|
            if isShowDialog {
 | 
						|
                SodaDialog(
 | 
						|
                    title: "포인트 지급",
 | 
						|
                    desc: message,
 | 
						|
                    confirmButtonTitle: "확인"
 | 
						|
                ) {
 | 
						|
                    isShowDialog = false
 | 
						|
                    message = ""
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        .onReceive(NotificationCenter.default.publisher(for: .pointGranted)) {
 | 
						|
            if let msg = $0.object as? String {
 | 
						|
                self.message = msg
 | 
						|
                self.isShowDialog = true
 | 
						|
            }
 | 
						|
        }
 | 
						|
        .popup(isPresented: $appState.isShowErrorPopup, type: .toast, position: .top, autohideIn: 1) {
 | 
						|
            GeometryReader { geo in
 | 
						|
                HStack {
 | 
						|
                    Spacer()
 | 
						|
                    Text(appState.errorMessage)
 | 
						|
                        .padding(.vertical, 13.3)
 | 
						|
                        .frame(width: geo.size.width - 66.7, alignment: .center)
 | 
						|
                        .font(.custom(Font.medium.rawValue, size: 12))
 | 
						|
                        .background(Color.button)
 | 
						|
                        .foregroundColor(Color.white)
 | 
						|
                        .multilineTextAlignment(.center)
 | 
						|
                        .cornerRadius(20)
 | 
						|
                        .padding(.top, 66.7)
 | 
						|
                    Spacer()
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct ContentView_Previews: PreviewProvider {
 | 
						|
    static var previews: some View {
 | 
						|
        ContentView(canPgPaymentViewModel: CanPgPaymentViewModel())
 | 
						|
    }
 | 
						|
}
 |