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

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

View File

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