feat(creator): 커뮤니티 아이템 표시를 통일한다

This commit is contained in:
Yu Sung
2026-08-10 15:11:02 +09:00
parent 89c070875c
commit c372d4a522
15 changed files with 1377 additions and 183 deletions

View File

@@ -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)