// // CreatorCommunityItemView.swift // SodaLive // // Created by klaus on 2023/12/14. // import SwiftUI import Kingfisher struct CreatorCommunityItemView: View { let item: GetCommunityPostListResponse var body: some View { VStack(alignment: .leading, spacing: 8) { HStack(spacing: 11) { KFImage(URL(string: item.creatorProfileUrl)) .cancelOnDisappear(true) .resizable() .frame(width: 40, height: 40) .clipShape(Circle()) VStack(alignment: .leading, spacing: 0) { Text(item.creatorNickname) .font(.custom(Font.preBold.rawValue, size: 18)) .foregroundColor(Color.white) Text(item.date) .font(.custom(Font.preRegular.rawValue, size: 14)) .foregroundColor(Color(hex: "78909C")) } Spacer() } HStack(spacing: 0) { Text(item.content) .font(.custom(Font.preRegular.rawValue, size: 18)) .foregroundColor(Color(hex: "B0BEC5")) .fixedSize(horizontal: false, vertical: true) .lineLimit(3) .truncationMode(.tail) Spacer() if let imageUrl = item.imageUrl { KFImage(URL(string: imageUrl)) .cancelOnDisappear(true) .resizable() .frame(width: 64, height: 64) .cornerRadius(12) .blur(radius: item.existOrdered || item.price <= 0 ? 0 : 15) } else { Rectangle() .foregroundColor(Color.gray22.opacity(0)) .frame(width: 64, height: 64) } } HStack(spacing: 13.3) { HStack(spacing: 4) { Image("ic_heart_78909c") .resizable() .frame(width: 24, height: 24) Text("\(item.likeCount)") .font(.custom(Font.preRegular.rawValue, size: 18)) .foregroundColor(Color(hex: "78909C")) } HStack(spacing: 4) { Image("ic_comment_78909c") .resizable() .frame(width: 24, height: 24) Text("\(item.commentCount)") .font(.custom(Font.preRegular.rawValue, size: 18)) .foregroundColor(Color(hex: "78909C")) } } } .frame(maxWidth: .infinity, alignment: .leading) .padding(16) .background(Color(hex: "263238")) .cornerRadius(16) } } struct CreatorCommunityItemView_Previews: PreviewProvider { static var previews: some View { CreatorCommunityItemView( item: GetCommunityPostListResponse( postId: 1, creatorId: 1, creatorNickname: "민하나", creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png", imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", audioUrl: nil, content: "안녕하세요", price: 10, date: "3일전", isCommentAvailable: false, isAdult: false, isLike: false, existOrdered: false, likeCount: 10, commentCount: 0, firstComment: nil ) ) } }