feat(creator): 커뮤니티 게시글 상세를 연결한다
This commit is contained in:
@@ -4,6 +4,7 @@ struct CreatorChannelCommunityGridItem: View {
|
||||
let post: CreatorChannelCommunityPostItem
|
||||
let isOwnPost: Bool
|
||||
let onTapPurchase: () -> Void
|
||||
let onTapDetail: () -> Void
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
@@ -14,20 +15,10 @@ struct CreatorChannelCommunityGridItem: View {
|
||||
.overlay(paidPriceOverlay)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
} else if let imageUrl = post.imageUrl, !imageUrl.isEmpty {
|
||||
DownsampledKFImage(url: URL(string: imageUrl), size: CGSize(width: proxy.size.width, height: proxy.size.width))
|
||||
.frame(width: proxy.size.width, height: proxy.size.width)
|
||||
.aspectRatio(1, contentMode: .fill)
|
||||
.clipped()
|
||||
} else {
|
||||
Color.gray900
|
||||
|
||||
Text(fallbackText)
|
||||
.appFont(size: 12, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.multilineTextAlignment(.center)
|
||||
.lineLimit(3)
|
||||
.padding(SodaSpacing.s8)
|
||||
tileContent(proxy: proxy)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onTapDetail)
|
||||
}
|
||||
}
|
||||
.frame(width: proxy.size.width, height: proxy.size.width)
|
||||
@@ -47,6 +38,27 @@ struct CreatorChannelCommunityGridItem: View {
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func tileContent(proxy: GeometryProxy) -> some View {
|
||||
if let imageUrl = post.imageUrl, !imageUrl.isEmpty {
|
||||
DownsampledKFImage(url: URL(string: imageUrl), size: CGSize(width: proxy.size.width, height: proxy.size.width))
|
||||
.frame(width: proxy.size.width, height: proxy.size.width)
|
||||
.aspectRatio(1, contentMode: .fill)
|
||||
.clipped()
|
||||
} else {
|
||||
ZStack {
|
||||
Color.gray900
|
||||
|
||||
Text(fallbackText)
|
||||
.appFont(size: 12, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.multilineTextAlignment(.center)
|
||||
.lineLimit(3)
|
||||
.padding(SodaSpacing.s8)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var paidPriceOverlay: some View {
|
||||
VStack(spacing: SodaSpacing.s4) {
|
||||
Image("ic_new_community_lock")
|
||||
|
||||
@@ -8,9 +8,9 @@ struct CreatorChannelCommunityListItem: View {
|
||||
let isOwnPost: Bool
|
||||
let isOwnCreatorChannel: Bool
|
||||
let onTapLike: () -> Void
|
||||
let onTapComment: () -> Void
|
||||
let onTapMore: () -> Void
|
||||
let onTapPurchase: () -> Void
|
||||
let onTapDetail: () -> Void
|
||||
|
||||
@State private var localIsLike: Bool
|
||||
@State private var localLikeCount: Int
|
||||
@@ -22,17 +22,17 @@ struct CreatorChannelCommunityListItem: View {
|
||||
isOwnPost: Bool,
|
||||
isOwnCreatorChannel: Bool,
|
||||
onTapLike: @escaping () -> Void,
|
||||
onTapComment: @escaping () -> Void,
|
||||
onTapMore: @escaping () -> Void,
|
||||
onTapPurchase: @escaping () -> Void
|
||||
onTapPurchase: @escaping () -> Void,
|
||||
onTapDetail: @escaping () -> Void
|
||||
) {
|
||||
self.post = post
|
||||
self.isOwnPost = isOwnPost
|
||||
self.isOwnCreatorChannel = isOwnCreatorChannel
|
||||
self.onTapLike = onTapLike
|
||||
self.onTapComment = onTapComment
|
||||
self.onTapMore = onTapMore
|
||||
self.onTapPurchase = onTapPurchase
|
||||
self.onTapDetail = onTapDetail
|
||||
_localIsLike = State(initialValue: post.isLiked ?? false)
|
||||
_localLikeCount = State(initialValue: post.likeCount)
|
||||
}
|
||||
@@ -44,6 +44,7 @@ struct CreatorChannelCommunityListItem: View {
|
||||
}
|
||||
|
||||
header
|
||||
|
||||
contentText
|
||||
|
||||
if isPaidLocked {
|
||||
@@ -58,6 +59,8 @@ struct CreatorChannelCommunityListItem: View {
|
||||
.padding(SodaSpacing.s14)
|
||||
.background(Color.gray900)
|
||||
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
|
||||
.contentShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
|
||||
.onTapGesture(perform: onTapDetail)
|
||||
.onChange(of: post.isLiked) { newValue in
|
||||
localIsLike = newValue ?? false
|
||||
}
|
||||
@@ -81,21 +84,23 @@ struct CreatorChannelCommunityListItem: View {
|
||||
|
||||
private var header: some View {
|
||||
HStack(spacing: SodaSpacing.s8) {
|
||||
DownsampledKFImage(url: URL(string: post.creatorProfileUrl), size: CGSize(width: 42, height: 42))
|
||||
.background(Color.gray800)
|
||||
.clipShape(Circle())
|
||||
.frame(width: 42, height: 42)
|
||||
HStack(spacing: SodaSpacing.s8) {
|
||||
DownsampledKFImage(url: URL(string: post.creatorProfileUrl), size: CGSize(width: 42, height: 42))
|
||||
.background(Color.gray800)
|
||||
.clipShape(Circle())
|
||||
.frame(width: 42, height: 42)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(post.creatorNickname)
|
||||
.appFont(size: 14, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(post.creatorNickname)
|
||||
.appFont(size: 14, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
|
||||
Text(post.relativeTimeText())
|
||||
.appFont(size: 14, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
.lineLimit(1)
|
||||
Text(post.relativeTimeText())
|
||||
.appFont(size: 14, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
@@ -235,18 +240,15 @@ struct CreatorChannelCommunityListItem: View {
|
||||
}
|
||||
|
||||
if post.isCommentAvailable && !isPaidLocked {
|
||||
Button(action: onTapComment) {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image("ic_feed_community_reply")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Image("ic_feed_community_reply")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
|
||||
Text("\(post.commentCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray400)
|
||||
}
|
||||
Text("\(post.commentCount)")
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray400)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.frame(height: 24)
|
||||
|
||||
Reference in New Issue
Block a user