refactor(navigation): 전역 경로 기반 단일 내비게이션 흐름으로 전환한다
This commit is contained in:
@@ -15,303 +15,327 @@ struct ContentView: View {
|
||||
@State private var message = ""
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.black.ignoresSafeArea()
|
||||
|
||||
if appState.isRestartApp {
|
||||
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 .languageSettings:
|
||||
LanguageSettingsView()
|
||||
|
||||
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)
|
||||
NavigationStack(path: $appState.navigationPath) {
|
||||
ZStack {
|
||||
Color.black.ignoresSafeArea()
|
||||
|
||||
case .channelDonationAll(let creatorId):
|
||||
ChannelDonationAllView(creatorId: creatorId)
|
||||
if appState.isRestartApp {
|
||||
EmptyView()
|
||||
} else {
|
||||
HomeView()
|
||||
}
|
||||
|
||||
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, let creatorNickname, let isOriginal, let isCompleted):
|
||||
SeriesListAllView(creatorId: creatorId, creatorNickname: creatorNickname, isOriginal: isOriginal, isCompleted: isCompleted)
|
||||
|
||||
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)
|
||||
|
||||
case .contentAll(let isFree, let isPointOnly):
|
||||
ContentAllView(isFree: isFree, isPointAvailableOnly: isPointOnly)
|
||||
|
||||
case .seriesMain:
|
||||
SeriesMainView()
|
||||
|
||||
default:
|
||||
EmptyView()
|
||||
.frame(width: 0, height: 0, alignment: .topLeading)
|
||||
if case .splash = appState.rootStep {
|
||||
AppStepLayerView(step: .splash, canPgPaymentViewModel: canPgPaymentViewModel)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
}
|
||||
|
||||
if isShowDialog {
|
||||
SodaDialog(
|
||||
title: I18n.Common.pointGrantTitle,
|
||||
desc: message,
|
||||
confirmButtonTitle: I18n.Common.confirm
|
||||
) {
|
||||
isShowDialog = false
|
||||
message = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isShowDialog {
|
||||
SodaDialog(
|
||||
title: I18n.Common.pointGrantTitle,
|
||||
desc: message,
|
||||
confirmButtonTitle: I18n.Common.confirm
|
||||
) {
|
||||
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)
|
||||
.appFont(size: 12, weight: .medium)
|
||||
.background(Color.button)
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.center)
|
||||
.cornerRadius(20)
|
||||
.padding(.top, 66.7)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationDestination(for: AppRoute.self) { route in
|
||||
if let step = appState.appStep(for: route) {
|
||||
AppStepLayerView(step: step, canPgPaymentViewModel: canPgPaymentViewModel)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
} else {
|
||||
EmptyView()
|
||||
.frame(width: 0, height: 0, alignment: .topLeading)
|
||||
}
|
||||
}
|
||||
}
|
||||
.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)
|
||||
.appFont(size: 12, weight: .medium)
|
||||
.background(Color.button)
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.center)
|
||||
.cornerRadius(20)
|
||||
.padding(.top, 66.7)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AppStepLayerView: View {
|
||||
let step: AppStep
|
||||
@ObservedObject var canPgPaymentViewModel: CanPgPaymentViewModel
|
||||
|
||||
@ViewBuilder
|
||||
var body: some View {
|
||||
switch step {
|
||||
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 .languageSettings:
|
||||
LanguageSettingsView()
|
||||
|
||||
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 .channelDonationAll(let creatorId):
|
||||
ChannelDonationAllView(creatorId: creatorId)
|
||||
|
||||
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, let creatorNickname, let isOriginal, let isCompleted):
|
||||
SeriesListAllView(creatorId: creatorId, creatorNickname: creatorNickname, isOriginal: isOriginal, isCompleted: isCompleted)
|
||||
|
||||
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)
|
||||
|
||||
case .contentAll(let isFree, let isPointOnly):
|
||||
ContentAllView(isFree: isFree, isPointAvailableOnly: isPointOnly)
|
||||
|
||||
case .seriesMain:
|
||||
SeriesMainView()
|
||||
|
||||
case .main:
|
||||
EmptyView()
|
||||
.frame(width: 0, height: 0, alignment: .topLeading)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user