feat(creator): 커뮤니티 아이템 표시를 통일한다
This commit is contained in:
@@ -3,26 +3,22 @@ import SwiftUI
|
||||
struct CreatorChannelCommunityGridItem: View {
|
||||
let post: CreatorChannelCommunityPostItem
|
||||
let isOwnPost: Bool
|
||||
let onTapPurchase: () -> Void
|
||||
let onTapDetail: () -> Void
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
ZStack {
|
||||
if isPaidLocked {
|
||||
Button(action: onTapPurchase) {
|
||||
Color.gray400
|
||||
.overlay(paidPriceOverlay)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
Color.gray800
|
||||
.overlay(paidPriceOverlay)
|
||||
} else {
|
||||
tileContent(proxy: proxy)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onTapDetail)
|
||||
}
|
||||
}
|
||||
.frame(width: proxy.size.width, height: proxy.size.width)
|
||||
.clipped()
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onTapDetail)
|
||||
.overlay(alignment: .topTrailing) {
|
||||
if post.isPinned {
|
||||
Image("ic_pin")
|
||||
@@ -92,3 +88,32 @@ struct CreatorChannelCommunityGridItem: View {
|
||||
return String(content.prefix(18))
|
||||
}
|
||||
}
|
||||
|
||||
struct CreatorChannelCommunityGridItem_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CreatorChannelCommunityGridItem(
|
||||
post: CreatorChannelCommunityPostItem(
|
||||
postId: 1,
|
||||
creatorId: 10,
|
||||
creatorNickname: "크리에이터 이름",
|
||||
creatorProfileUrl: "https://picsum.photos/600",
|
||||
createdAtUtc: "2026-08-10T00:00:00Z",
|
||||
content: "유료 커뮤니티 게시글",
|
||||
imageUrl: nil,
|
||||
audioUrl: nil,
|
||||
price: 30,
|
||||
isCommentAvailable: true,
|
||||
likeCount: 5,
|
||||
commentCount: 2,
|
||||
isPinned: true,
|
||||
existOrdered: false,
|
||||
isLiked: false
|
||||
),
|
||||
isOwnPost: false,
|
||||
onTapDetail: {}
|
||||
)
|
||||
.frame(width: 134, height: 134)
|
||||
.background(Color.black)
|
||||
.previewLayout(.sizeThatFits)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ struct CreatorChannelCommunityListItem: View {
|
||||
let isOwnCreatorChannel: Bool
|
||||
let onTapLike: () -> Void
|
||||
let onTapMore: () -> Void
|
||||
let onTapPurchase: () -> Void
|
||||
let onTapDetail: () -> Void
|
||||
|
||||
@State private var localIsLike: Bool
|
||||
@@ -23,7 +22,6 @@ struct CreatorChannelCommunityListItem: View {
|
||||
isOwnCreatorChannel: Bool,
|
||||
onTapLike: @escaping () -> Void,
|
||||
onTapMore: @escaping () -> Void,
|
||||
onTapPurchase: @escaping () -> Void,
|
||||
onTapDetail: @escaping () -> Void
|
||||
) {
|
||||
self.post = post
|
||||
@@ -31,7 +29,6 @@ struct CreatorChannelCommunityListItem: View {
|
||||
self.isOwnCreatorChannel = isOwnCreatorChannel
|
||||
self.onTapLike = onTapLike
|
||||
self.onTapMore = onTapMore
|
||||
self.onTapPurchase = onTapPurchase
|
||||
self.onTapDetail = onTapDetail
|
||||
_localIsLike = State(initialValue: post.isLiked ?? false)
|
||||
_localLikeCount = State(initialValue: post.likeCount)
|
||||
@@ -53,7 +50,9 @@ struct CreatorChannelCommunityListItem: View {
|
||||
imageContent(imageUrl: imageUrl)
|
||||
}
|
||||
|
||||
reactionBar
|
||||
if !isPaidLocked {
|
||||
reactionBar
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(SodaSpacing.s14)
|
||||
@@ -172,14 +171,11 @@ struct CreatorChannelCommunityListItem: View {
|
||||
}
|
||||
|
||||
private var paidLockedImage: some View {
|
||||
Button(action: onTapPurchase) {
|
||||
RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous)
|
||||
.fill(Color.gray400)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 236)
|
||||
.overlay(paidPriceOverlay)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous)
|
||||
.fill(Color.gray800)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 236)
|
||||
.overlay(paidPriceOverlay)
|
||||
}
|
||||
|
||||
private var paidPriceOverlay: some View {
|
||||
@@ -219,7 +215,7 @@ struct CreatorChannelCommunityListItem: View {
|
||||
|
||||
private var reactionBar: some View {
|
||||
HStack(spacing: 15) {
|
||||
if post.isCommentAvailable && !isPaidLocked {
|
||||
if post.isCommentAvailable {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image("ic_feed_community_reply")
|
||||
.resizable()
|
||||
@@ -231,25 +227,23 @@ struct CreatorChannelCommunityListItem: View {
|
||||
}
|
||||
}
|
||||
|
||||
if !isPaidLocked {
|
||||
Button {
|
||||
localIsLike.toggle()
|
||||
localLikeCount += localIsLike ? 1 : -1
|
||||
localLikeCount = max(0, localLikeCount)
|
||||
onTapLike()
|
||||
} label: {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image(localIsLike ? "ic_feed_community_heart_fill" : "ic_feed_community_heart")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
Button {
|
||||
localIsLike.toggle()
|
||||
localLikeCount += localIsLike ? 1 : -1
|
||||
localLikeCount = max(0, localLikeCount)
|
||||
onTapLike()
|
||||
} label: {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image(localIsLike ? "ic_feed_community_heart_fill" : "ic_feed_community_heart")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
|
||||
Text("\(localLikeCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray400)
|
||||
}
|
||||
Text("\(localLikeCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray400)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.frame(height: 24)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct CreatorChannelCommunityTabView: View {
|
||||
let creatorId: Int
|
||||
let isOwnCreatorChannel: Bool
|
||||
@ObservedObject var viewModel: CreatorChannelCommunityViewModel
|
||||
let onTapDetail: (CreatorChannelCommunityPostItem) -> Void
|
||||
let onTapDetail: (Int) -> Void
|
||||
|
||||
private let gridColumns = [
|
||||
GridItem(.flexible(), spacing: 0),
|
||||
@@ -69,11 +69,8 @@ struct CreatorChannelCommunityTabView: View {
|
||||
onTapMore: {
|
||||
viewModel.openReportMenu(post: post)
|
||||
},
|
||||
onTapPurchase: {
|
||||
viewModel.openPurchaseDialog(post: post)
|
||||
},
|
||||
onTapDetail: {
|
||||
onTapDetail(post)
|
||||
onTapDetail(post.postId)
|
||||
}
|
||||
)
|
||||
.onAppear {
|
||||
@@ -95,11 +92,8 @@ struct CreatorChannelCommunityTabView: View {
|
||||
CreatorChannelCommunityGridItem(
|
||||
post: post,
|
||||
isOwnPost: isOwnPost,
|
||||
onTapPurchase: {
|
||||
viewModel.openPurchaseDialog(post: post)
|
||||
},
|
||||
onTapDetail: {
|
||||
onTapDetail(post)
|
||||
onTapDetail(post.postId)
|
||||
}
|
||||
)
|
||||
.onAppear {
|
||||
|
||||
@@ -50,16 +50,7 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Published var isShowPostPurchaseView = false {
|
||||
didSet {
|
||||
if !isShowPostPurchaseView {
|
||||
selectedPostId = 0
|
||||
selectedPostPrice = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@Published var selectedPostId = 0
|
||||
@Published var selectedPostPrice = 0
|
||||
@Published var selectedPostIsPinned = false
|
||||
@Published var isShowSecret = false
|
||||
|
||||
@@ -94,17 +85,10 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
|
||||
func openReportMenu(post: CreatorChannelCommunityPostItem) {
|
||||
selectedPostId = post.postId
|
||||
selectedPostPrice = post.price
|
||||
selectedPostIsPinned = post.isPinned
|
||||
isShowReportMenu = true
|
||||
}
|
||||
|
||||
func openPurchaseDialog(post: CreatorChannelCommunityPostItem) {
|
||||
selectedPostId = post.postId
|
||||
selectedPostPrice = post.price
|
||||
isShowPostPurchaseView = true
|
||||
}
|
||||
|
||||
func communityPostLike(postId: Int) {
|
||||
communityRepository.communityPostLike(postId: postId)
|
||||
.sink { result in
|
||||
@@ -153,7 +137,7 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func deleteCommunityPost(creatorId: Int) {
|
||||
func deleteCommunityPost(onSuccess: @escaping () -> Void) {
|
||||
guard selectedPostId > 0 else { return }
|
||||
|
||||
isLoading = true
|
||||
@@ -190,7 +174,7 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
if decoded.success {
|
||||
self.errorMessage = I18n.Explorer.deleted
|
||||
self.isShowPopup = true
|
||||
self.fetchFirstPage(creatorId: creatorId)
|
||||
onSuccess()
|
||||
} else {
|
||||
self.errorMessage = decoded.message ?? I18n.Common.commonError
|
||||
self.isShowPopup = true
|
||||
@@ -204,7 +188,7 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func updateCommunityPostFixed(creatorId: Int) {
|
||||
func updateCommunityPostFixed(onSuccess: @escaping () -> Void) {
|
||||
guard selectedPostId > 0 else { return }
|
||||
|
||||
isLoading = true
|
||||
@@ -228,7 +212,7 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
do {
|
||||
let decoded = try JSONDecoder().decode(ApiResponseWithoutData.self, from: response.data)
|
||||
if decoded.success {
|
||||
self.fetchFirstPage(creatorId: creatorId)
|
||||
onSuccess()
|
||||
} else {
|
||||
self.errorMessage = decoded.message ?? I18n.Common.commonError
|
||||
self.isShowPopup = true
|
||||
@@ -242,43 +226,6 @@ final class CreatorChannelCommunityViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func purchaseCommunityPost(creatorId: Int) {
|
||||
guard selectedPostId > 0 else { return }
|
||||
|
||||
isLoading = true
|
||||
communityRepository.purchaseCommunityPost(postId: selectedPostId)
|
||||
.sink { [weak self] result in
|
||||
guard let self else { return }
|
||||
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
self.applyFailureState()
|
||||
}
|
||||
} receiveValue: { [weak self] response in
|
||||
guard let self else { return }
|
||||
|
||||
self.isLoading = false
|
||||
self.selectedPostId = 0
|
||||
|
||||
do {
|
||||
let decoded = try JSONDecoder().decode(ApiResponseWithoutData.self, from: response.data)
|
||||
if decoded.success {
|
||||
self.fetchFirstPage(creatorId: creatorId)
|
||||
} else {
|
||||
self.errorMessage = decoded.message ?? I18n.Common.commonError
|
||||
self.isShowPopup = true
|
||||
}
|
||||
} catch {
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
self.fetchFirstPage(creatorId: creatorId)
|
||||
}
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
private func fetchCommunity(creatorId: Int, page requestPage: Int, isNextPage: Bool) {
|
||||
latestRequestId += 1
|
||||
let requestId = latestRequestId
|
||||
|
||||
@@ -25,7 +25,9 @@ struct CreatorChannelCommunityPostDetailContentView: View {
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
mediaContent
|
||||
reactionBar
|
||||
if !isPaidLocked {
|
||||
reactionBar
|
||||
}
|
||||
}
|
||||
.padding(SodaSpacing.s14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -154,32 +156,30 @@ struct CreatorChannelCommunityPostDetailContentView: View {
|
||||
|
||||
private var reactionBar: some View {
|
||||
HStack(spacing: 15) {
|
||||
if isPaidLocked == false {
|
||||
if detail.isCommentAvailable {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image("ic_feed_community_reply")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
if detail.isCommentAvailable {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image("ic_feed_community_reply")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
|
||||
Text("\(detail.commentCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
}
|
||||
Text("\(detail.commentCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
}
|
||||
|
||||
Button(action: onTapLike) {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image(detail.isLiked ? "ic_feed_community_heart_fill" : "ic_feed_community_heart")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
|
||||
Text("\(detail.likeCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
Button(action: onTapLike) {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image(detail.isLiked ? "ic_feed_community_heart_fill" : "ic_feed_community_heart")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
|
||||
Text("\(detail.likeCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.frame(height: 24)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ struct CreatorChannelCommunityPostDetailView: View {
|
||||
CreatorChannelCommunityPostDetailContentView(
|
||||
detail: detail,
|
||||
onTapLike: viewModel.toggleLike,
|
||||
onTapPurchase: showPurchaseError
|
||||
onTapPurchase: viewModel.presentPurchaseDialog
|
||||
)
|
||||
|
||||
if detail.isCommentAvailable {
|
||||
@@ -69,6 +69,14 @@ struct CreatorChannelCommunityPostDetailView: View {
|
||||
onDimmedTap: dismissDeleteDialog
|
||||
)
|
||||
}
|
||||
|
||||
if viewModel.isShowPurchaseDialog, let detail = viewModel.detail {
|
||||
CommunityPostPurchaseDialog(
|
||||
isShowing: $viewModel.isShowPurchaseDialog,
|
||||
can: detail.price,
|
||||
confirmAction: viewModel.purchaseCommunityPost
|
||||
)
|
||||
}
|
||||
}
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.onAppear {
|
||||
@@ -112,9 +120,4 @@ struct CreatorChannelCommunityPostDetailView: View {
|
||||
)
|
||||
}
|
||||
|
||||
private func showPurchaseError() {
|
||||
viewModel.errorMessage = I18n.Common.commonError
|
||||
viewModel.isShowPopup = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
|
||||
@Published var editingComment: CreatorChannelCommunityCommentResponse?
|
||||
@Published var deletingComment: CreatorChannelCommunityCommentResponse?
|
||||
@Published var isShowDeleteDialog = false
|
||||
@Published var isShowPurchaseDialog = false
|
||||
@Published var page = 0
|
||||
@Published var size = 20
|
||||
@Published var hasNext = false
|
||||
@@ -182,6 +183,49 @@ final class CreatorChannelCommunityPostDetailViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func presentPurchaseDialog() {
|
||||
guard let detail, detail.price > 0, detail.existOrdered == false, isOwnPost == false else { return }
|
||||
isShowPurchaseDialog = true
|
||||
}
|
||||
|
||||
func purchaseCommunityPost() {
|
||||
guard postId > 0, isLoading == false else { return }
|
||||
|
||||
isLoading = true
|
||||
communityRepository.purchaseCommunityPost(postId: postId)
|
||||
.sink { [weak self] result in
|
||||
guard let self else { return }
|
||||
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
self.applyFailureState()
|
||||
}
|
||||
} receiveValue: { [weak self] response in
|
||||
guard let self else { return }
|
||||
|
||||
self.isLoading = false
|
||||
|
||||
do {
|
||||
let decoded = try JSONDecoder().decode(ApiResponseWithoutData.self, from: response.data)
|
||||
if decoded.success {
|
||||
self.onCommunityRefresh?()
|
||||
self.fetchDetail(postId: self.postId)
|
||||
} else {
|
||||
self.errorMessage = decoded.message ?? I18n.Common.commonError
|
||||
self.isShowPopup = true
|
||||
}
|
||||
} catch {
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
self.errorMessage = I18n.Common.commonError
|
||||
self.isShowPopup = true
|
||||
}
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func sendComment() {
|
||||
guard isCommentSendEnabled else { return }
|
||||
|
||||
|
||||
@@ -321,13 +321,16 @@ struct CreatorChannelView: View {
|
||||
} else if let response = viewModel.response {
|
||||
CreatorChannelHomeView(
|
||||
response: response,
|
||||
isOwnCreatorChannel: isOwnCreatorChannel,
|
||||
onSelectTab: selectTab,
|
||||
onTapLive: showLiveDetail,
|
||||
onTapContent: showContentDetail,
|
||||
onTapDonate: showDonationDialog,
|
||||
onTapSchedule: handleScheduleTap,
|
||||
onTapSeries: showSeriesDetail,
|
||||
onTapCommunityLike: viewModel.likeCommunityPost
|
||||
onTapCommunityLike: viewModel.likeCommunityPost,
|
||||
onTapCommunityMore: communityViewModel.openReportMenu,
|
||||
onTapCommunityDetail: showCommunityPostDetail
|
||||
)
|
||||
} else {
|
||||
EmptyView()
|
||||
@@ -474,17 +477,22 @@ struct CreatorChannelView: View {
|
||||
)
|
||||
}
|
||||
|
||||
private func showCommunityPostDetail(_ post: CreatorChannelCommunityPostItem) {
|
||||
private func showCommunityPostDetail(_ postId: Int) {
|
||||
AppState.shared.setAppStep(
|
||||
step: .creatorChannelCommunityPostDetail(
|
||||
postId: post.postId,
|
||||
postId: postId,
|
||||
onCommunityRefresh: {
|
||||
communityViewModel.fetchFirstPage(creatorId: creatorId)
|
||||
refreshCommunityFeeds()
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private func refreshCommunityFeeds() {
|
||||
viewModel.fetchHome(creatorId: creatorId)
|
||||
communityViewModel.fetchFirstPage(creatorId: creatorId)
|
||||
}
|
||||
|
||||
private func showAudioContentUpload() {
|
||||
isCreatorActionMenuPresented = false
|
||||
AppState.shared.setAppStep(
|
||||
@@ -595,7 +603,7 @@ struct CreatorChannelView: View {
|
||||
|
||||
@ViewBuilder
|
||||
private func communityOverlay(proxy: GeometryProxy) -> some View {
|
||||
if viewModel.selectedTab == .community {
|
||||
if viewModel.selectedTab == .home || viewModel.selectedTab == .community {
|
||||
if communityViewModel.isShowReportMenu {
|
||||
VStack(spacing: 0) {
|
||||
CreatorCommunityMenuView(
|
||||
@@ -603,7 +611,7 @@ struct CreatorChannelView: View {
|
||||
isShowCreatorMenu: isOwnCreatorChannel,
|
||||
isFixed: communityViewModel.selectedPostIsPinned,
|
||||
fixedAction: {
|
||||
communityViewModel.updateCommunityPostFixed(creatorId: creatorId)
|
||||
communityViewModel.updateCommunityPostFixed(onSuccess: refreshCommunityFeeds)
|
||||
},
|
||||
modifyAction: showCommunityModify,
|
||||
deleteAction: {
|
||||
@@ -638,7 +646,7 @@ struct CreatorChannelView: View {
|
||||
button1: SodaV2ActionModalButton(
|
||||
label: I18n.Common.delete,
|
||||
action: {
|
||||
communityViewModel.deleteCommunityPost(creatorId: creatorId)
|
||||
communityViewModel.deleteCommunityPost(onSuccess: refreshCommunityFeeds)
|
||||
communityViewModel.isShowDeleteConfirm = false
|
||||
}
|
||||
),
|
||||
@@ -650,16 +658,6 @@ struct CreatorChannelView: View {
|
||||
)
|
||||
}
|
||||
|
||||
if communityViewModel.isShowPostPurchaseView {
|
||||
CommunityPostPurchaseDialog(
|
||||
isShowing: $communityViewModel.isShowPostPurchaseView,
|
||||
can: communityViewModel.selectedPostPrice,
|
||||
confirmAction: {
|
||||
communityViewModel.purchaseCommunityPost(creatorId: creatorId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if communityViewModel.isLoading {
|
||||
LoadingView()
|
||||
}
|
||||
@@ -674,7 +672,7 @@ struct CreatorChannelView: View {
|
||||
step: .creatorCommunityModify(
|
||||
postId: postId,
|
||||
onSuccess: {
|
||||
communityViewModel.fetchFirstPage(creatorId: creatorId)
|
||||
refreshCommunityFeeds()
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2,25 +2,28 @@ import SwiftUI
|
||||
|
||||
struct CreatorChannelCommunitySection: View {
|
||||
let communities: [CreatorChannelCommunityPostResponse]
|
||||
let isOwnCreatorChannel: Bool
|
||||
let onSelectTab: (CreatorChannelTab) -> Void
|
||||
let onTapLike: (Int) -> Void
|
||||
let onTapComment: (Int) -> Void
|
||||
let onTapPurchase: (CreatorChannelCommunityPostResponse) -> Void
|
||||
let onTapMore: (CreatorChannelCommunityPostItem) -> Void
|
||||
let onTapDetail: (Int) -> Void
|
||||
|
||||
private let homeVisibleCount = 3
|
||||
|
||||
init(
|
||||
communities: [CreatorChannelCommunityPostResponse],
|
||||
isOwnCreatorChannel: Bool,
|
||||
onSelectTab: @escaping (CreatorChannelTab) -> Void,
|
||||
onTapLike: @escaping (Int) -> Void = { _ in },
|
||||
onTapComment: @escaping (Int) -> Void = { _ in },
|
||||
onTapPurchase: @escaping (CreatorChannelCommunityPostResponse) -> Void = { _ in }
|
||||
onTapMore: @escaping (CreatorChannelCommunityPostItem) -> Void = { _ in },
|
||||
onTapDetail: @escaping (Int) -> Void = { _ in }
|
||||
) {
|
||||
self.communities = communities
|
||||
self.isOwnCreatorChannel = isOwnCreatorChannel
|
||||
self.onSelectTab = onSelectTab
|
||||
self.onTapLike = onTapLike
|
||||
self.onTapComment = onTapComment
|
||||
self.onTapPurchase = onTapPurchase
|
||||
self.onTapMore = onTapMore
|
||||
self.onTapDetail = onTapDetail
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -30,27 +33,21 @@ struct CreatorChannelCommunitySection: View {
|
||||
|
||||
VStack(alignment: .leading, spacing: SodaSpacing.s8) {
|
||||
ForEach(visibleCommunities) { community in
|
||||
CommunityPostCard(
|
||||
postId: community.postId,
|
||||
creatorNickname: community.creatorNickname,
|
||||
creatorProfileImageUrl: community.creatorProfileUrl,
|
||||
content: community.content,
|
||||
imageUrl: community.imageUrl,
|
||||
audioUrl: community.audioUrl,
|
||||
price: community.price,
|
||||
existOrdered: community.existOrdered,
|
||||
createdAt: community.relativeTimeText(),
|
||||
isLike: community.isLiked,
|
||||
likeCount: community.likeCount,
|
||||
commentCount: community.commentCount,
|
||||
let post = community.communityPostItem
|
||||
let isOwnPost = post.creatorId == UserDefaults.int(forKey: .userId)
|
||||
|
||||
CreatorChannelCommunityListItem(
|
||||
post: post,
|
||||
isOwnPost: isOwnPost,
|
||||
isOwnCreatorChannel: isOwnCreatorChannel,
|
||||
onTapLike: {
|
||||
onTapLike(community.postId)
|
||||
onTapLike(post.postId)
|
||||
},
|
||||
onTapComment: {
|
||||
onTapComment(community.postId)
|
||||
onTapMore: {
|
||||
onTapMore(post)
|
||||
},
|
||||
onTapPurchase: {
|
||||
onTapPurchase(community)
|
||||
onTapDetail: {
|
||||
onTapDetail(post.postId)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -83,8 +80,24 @@ struct CreatorChannelCommunitySection: View {
|
||||
}
|
||||
|
||||
private extension CreatorChannelCommunityPostResponse {
|
||||
func relativeTimeText(now: Date = Date()) -> String {
|
||||
DateParser.relativeTimeText(fromUTC: dateUtc, fallback: dateUtc, now: now)
|
||||
var communityPostItem: CreatorChannelCommunityPostItem {
|
||||
CreatorChannelCommunityPostItem(
|
||||
postId: postId,
|
||||
creatorId: creatorId,
|
||||
creatorNickname: creatorNickname,
|
||||
creatorProfileUrl: creatorProfileUrl,
|
||||
createdAtUtc: dateUtc,
|
||||
content: content,
|
||||
imageUrl: imageUrl,
|
||||
audioUrl: audioUrl,
|
||||
price: price,
|
||||
isCommentAvailable: isCommentAvailable,
|
||||
likeCount: likeCount,
|
||||
commentCount: commentCount,
|
||||
isPinned: isPinned,
|
||||
existOrdered: existOrdered,
|
||||
isLiked: isLiked
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,10 +120,15 @@ struct CreatorChannelCommunitySection_Previews: PreviewProvider {
|
||||
existOrdered: false,
|
||||
likeCount: 5,
|
||||
commentCount: 6,
|
||||
isLiked: false
|
||||
isLiked: false,
|
||||
isCommentAvailable: index != 3,
|
||||
isPinned: index == 1
|
||||
)
|
||||
},
|
||||
onSelectTab: { _ in }
|
||||
isOwnCreatorChannel: true,
|
||||
onSelectTab: { _ in },
|
||||
onTapMore: { _ in },
|
||||
onTapDetail: { _ in }
|
||||
)
|
||||
.background(Color.black)
|
||||
.previewLayout(.sizeThatFits)
|
||||
|
||||
@@ -264,7 +264,9 @@ struct CreatorChannelNoticeSection_Previews: PreviewProvider {
|
||||
existOrdered: true,
|
||||
likeCount: 5,
|
||||
commentCount: 2,
|
||||
isLiked: false
|
||||
isLiked: false,
|
||||
isCommentAvailable: true,
|
||||
isPinned: true
|
||||
),
|
||||
CreatorChannelCommunityPostResponse(
|
||||
postId: 2,
|
||||
@@ -279,7 +281,9 @@ struct CreatorChannelNoticeSection_Previews: PreviewProvider {
|
||||
existOrdered: false,
|
||||
likeCount: 3,
|
||||
commentCount: 1,
|
||||
isLiked: false
|
||||
isLiked: false,
|
||||
isCommentAvailable: true,
|
||||
isPinned: false
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@ import SwiftUI
|
||||
|
||||
struct CreatorChannelHomeView: View {
|
||||
let response: CreatorChannelHomeResponse
|
||||
let isOwnCreatorChannel: Bool
|
||||
let onSelectTab: (CreatorChannelTab) -> Void
|
||||
let onTapLive: (Int) -> Void
|
||||
let onTapContent: (Int) -> Void
|
||||
@@ -9,18 +10,24 @@ struct CreatorChannelHomeView: View {
|
||||
let onTapSchedule: (CreatorActivityType, Int) -> Void
|
||||
let onTapSeries: (Int) -> Void
|
||||
let onTapCommunityLike: (Int) -> Void
|
||||
let onTapCommunityMore: (CreatorChannelCommunityPostItem) -> Void
|
||||
let onTapCommunityDetail: (Int) -> Void
|
||||
|
||||
init(
|
||||
response: CreatorChannelHomeResponse,
|
||||
isOwnCreatorChannel: Bool,
|
||||
onSelectTab: @escaping (CreatorChannelTab) -> Void,
|
||||
onTapLive: @escaping (Int) -> Void = { _ in },
|
||||
onTapContent: @escaping (Int) -> Void = { _ in },
|
||||
onTapDonate: @escaping () -> Void = {},
|
||||
onTapSchedule: @escaping (CreatorActivityType, Int) -> Void = { _, _ in },
|
||||
onTapSeries: @escaping (Int) -> Void = { _ in },
|
||||
onTapCommunityLike: @escaping (Int) -> Void = { _ in }
|
||||
onTapCommunityLike: @escaping (Int) -> Void = { _ in },
|
||||
onTapCommunityMore: @escaping (CreatorChannelCommunityPostItem) -> Void = { _ in },
|
||||
onTapCommunityDetail: @escaping (Int) -> Void = { _ in }
|
||||
) {
|
||||
self.response = response
|
||||
self.isOwnCreatorChannel = isOwnCreatorChannel
|
||||
self.onSelectTab = onSelectTab
|
||||
self.onTapLive = onTapLive
|
||||
self.onTapContent = onTapContent
|
||||
@@ -28,6 +35,8 @@ struct CreatorChannelHomeView: View {
|
||||
self.onTapSchedule = onTapSchedule
|
||||
self.onTapSeries = onTapSeries
|
||||
self.onTapCommunityLike = onTapCommunityLike
|
||||
self.onTapCommunityMore = onTapCommunityMore
|
||||
self.onTapCommunityDetail = onTapCommunityDetail
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -69,8 +78,11 @@ struct CreatorChannelHomeView: View {
|
||||
|
||||
CreatorChannelCommunitySection(
|
||||
communities: response.communities,
|
||||
isOwnCreatorChannel: isOwnCreatorChannel,
|
||||
onSelectTab: onSelectTab,
|
||||
onTapLike: onTapCommunityLike
|
||||
onTapLike: onTapCommunityLike,
|
||||
onTapMore: onTapCommunityMore,
|
||||
onTapDetail: onTapCommunityDetail
|
||||
)
|
||||
|
||||
CreatorChannelFanTalkSection(
|
||||
|
||||
@@ -98,6 +98,8 @@ struct CreatorChannelCommunityPostResponse: Decodable, Identifiable {
|
||||
let likeCount: Int
|
||||
let commentCount: Int
|
||||
let isLiked: Bool
|
||||
let isCommentAvailable: Bool
|
||||
let isPinned: Bool
|
||||
|
||||
var id: Int { postId }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user