feat(creator): 커뮤니티 탭을 추가한다
This commit is contained in:
@@ -9,6 +9,7 @@ struct CreatorChannelView: View {
|
||||
@StateObject private var channelDonationViewModel = ChannelDonationViewModel()
|
||||
@StateObject private var donationViewModel = CreatorChannelDonationViewModel()
|
||||
@StateObject private var fanTalkViewModel = CreatorChannelFanTalkViewModel()
|
||||
@StateObject private var communityViewModel = CreatorChannelCommunityViewModel()
|
||||
@StateObject private var liveViewModel = LiveViewModel()
|
||||
@StateObject private var mypageViewModel = MyPageViewModel()
|
||||
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
|
||||
@@ -142,6 +143,15 @@ struct CreatorChannelView: View {
|
||||
.padding(.bottom, SodaSpacing.s14)
|
||||
}
|
||||
|
||||
if isOwnCreatorChannel && viewModel.selectedTab == .community && !viewModel.isLoading {
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
CreatorChannelCommunityUploadButton(action: showCommunityWrite)
|
||||
}
|
||||
.ignoresSafeArea(.container, edges: .bottom)
|
||||
}
|
||||
|
||||
if isShowAuthConfirmView {
|
||||
authConfirmDialog
|
||||
}
|
||||
@@ -168,6 +178,8 @@ struct CreatorChannelView: View {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
communityOverlay(proxy: proxy)
|
||||
}
|
||||
}
|
||||
.navigationBarBackButtonHidden(true)
|
||||
@@ -281,6 +293,12 @@ struct CreatorChannelView: View {
|
||||
viewModel: fanTalkViewModel,
|
||||
onTapWrite: showFanTalkWriteView
|
||||
)
|
||||
} else if viewModel.selectedTab == .community {
|
||||
CreatorChannelCommunityTabView(
|
||||
creatorId: creatorId,
|
||||
isOwnCreatorChannel: isOwnCreatorChannel,
|
||||
viewModel: communityViewModel
|
||||
)
|
||||
} else if viewModel.selectedTab != .home {
|
||||
CreatorChannelPlaceholderTabView(title: viewModel.selectedTab.title)
|
||||
} else if let response = viewModel.response {
|
||||
@@ -404,6 +422,7 @@ struct CreatorChannelView: View {
|
||||
AppState.shared.setAppStep(
|
||||
step: .creatorCommunityWrite(onSuccess: {
|
||||
viewModel.fetchHome(creatorId: creatorId)
|
||||
communityViewModel.fetchFirstPage(creatorId: creatorId)
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -494,6 +513,92 @@ struct CreatorChannelView: View {
|
||||
isShowChannelDonationDialog = true
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func communityOverlay(proxy: GeometryProxy) -> some View {
|
||||
if viewModel.selectedTab == .community {
|
||||
if communityViewModel.isShowReportMenu {
|
||||
VStack(spacing: 0) {
|
||||
CreatorCommunityMenuView(
|
||||
isShowing: $communityViewModel.isShowReportMenu,
|
||||
isShowCreatorMenu: isOwnCreatorChannel,
|
||||
isFixed: communityViewModel.selectedPostIsPinned,
|
||||
fixedAction: {
|
||||
communityViewModel.updateCommunityPostFixed(creatorId: creatorId)
|
||||
},
|
||||
modifyAction: showCommunityModify,
|
||||
deleteAction: {
|
||||
if isOwnCreatorChannel {
|
||||
communityViewModel.isShowDeleteConfirm = true
|
||||
}
|
||||
},
|
||||
reportAction: {
|
||||
communityViewModel.isShowReportView = true
|
||||
}
|
||||
)
|
||||
|
||||
if proxy.safeAreaInsets.bottom > 0 {
|
||||
Rectangle()
|
||||
.foregroundColor(Color(hex: "222222"))
|
||||
.frame(width: proxy.size.width, height: 15.3)
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
|
||||
if communityViewModel.isShowReportView {
|
||||
CreatorCommunityReportView(isShowing: $communityViewModel.isShowReportView) { reason in
|
||||
communityViewModel.report(reason: reason)
|
||||
}
|
||||
}
|
||||
|
||||
if communityViewModel.isShowDeleteConfirm {
|
||||
SodaDialog(
|
||||
title: I18n.Common.postDeleteTitle,
|
||||
desc: I18n.Common.confirmDeleteQuestion,
|
||||
confirmButtonTitle: I18n.Common.delete,
|
||||
confirmButtonAction: {
|
||||
communityViewModel.deleteCommunityPost(creatorId: creatorId)
|
||||
communityViewModel.isShowDeleteConfirm = false
|
||||
},
|
||||
cancelButtonTitle: I18n.Common.cancel,
|
||||
cancelButtonAction: {
|
||||
communityViewModel.isShowDeleteConfirm = false
|
||||
},
|
||||
textAlignment: .center
|
||||
)
|
||||
}
|
||||
|
||||
if communityViewModel.isShowPostPurchaseView {
|
||||
CommunityPostPurchaseDialog(
|
||||
isShowing: $communityViewModel.isShowPostPurchaseView,
|
||||
can: communityViewModel.selectedPostPrice,
|
||||
confirmAction: {
|
||||
communityViewModel.purchaseCommunityPost(creatorId: creatorId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if communityViewModel.isLoading {
|
||||
LoadingView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func showCommunityModify() {
|
||||
let postId = communityViewModel.selectedPostId
|
||||
guard postId > 0 else { return }
|
||||
|
||||
AppState.shared.setAppStep(
|
||||
step: .creatorCommunityModify(
|
||||
postId: postId,
|
||||
onSuccess: {
|
||||
communityViewModel.fetchFirstPage(creatorId: creatorId)
|
||||
}
|
||||
)
|
||||
)
|
||||
communityViewModel.selectedPostId = 0
|
||||
}
|
||||
|
||||
private func showFanTalkWriteView() {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user