feat(main-home): 추천 홈 공용 컴포넌트를 추가한다

This commit is contained in:
Yu Sung
2026-06-12 15:08:22 +09:00
parent 016a8bcca3
commit ed5e92e1d6
15 changed files with 748 additions and 4 deletions

View File

@@ -0,0 +1,66 @@
import SwiftUI
struct AiCharacterCard: View {
let name: String
let description: String
let profileImageUrl: String?
let chatCount: Int?
let originalTitle: String?
var body: some View {
HStack(alignment: .top, spacing: SodaSpacing.s12) {
DownsampledKFImage(url: URL(string: profileImageUrl ?? ""), size: CGSize(width: 72, height: 72))
.background(Color.gray800)
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
VStack(alignment: .leading, spacing: SodaSpacing.s4) {
Text(name)
.appFont(.heading4)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
Text(description)
.appFont(.body5)
.foregroundColor(Color.gray500)
.lineLimit(2)
.truncationMode(.tail)
HStack(spacing: SodaSpacing.s8) {
if let chatCount {
Text("Chat \(chatCount)")
.appFont(.caption2)
.foregroundColor(Color.gray500)
}
if let originalTitle, !originalTitle.isEmpty {
Text(originalTitle)
.appFont(.caption2)
.foregroundColor(Color.gray500)
.lineLimit(1)
}
}
}
Spacer(minLength: 0)
}
.padding(SodaSpacing.s12)
.background(Color.gray900)
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
}
}
struct AiCharacterCard_Previews: PreviewProvider {
static var previews: some View {
AiCharacterCard(
name: "AI 캐릭터",
description: "캐릭터 설명이 표시됩니다.",
profileImageUrl: nil,
chatCount: 128,
originalTitle: "원작"
)
.padding(SodaSpacing.s20)
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}

View File

@@ -0,0 +1,130 @@
import SwiftUI
struct CommunityPostCard: View {
let creatorNickname: String
let creatorProfileImageUrl: String?
let content: String
let imageUrl: String?
let price: Int?
let existOrdered: Bool
let createdAt: String?
let likeCount: Int?
let commentCount: Int?
var body: some View {
VStack(alignment: .leading, spacing: SodaSpacing.s12) {
header
Text(content)
.appFont(.body4)
.foregroundColor(.white)
.lineLimit(3)
.truncationMode(.tail)
if hasImage {
imageContent
}
footer
}
.padding(SodaSpacing.s12)
.background(Color.gray900)
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
}
private var header: some View {
HStack(spacing: SodaSpacing.s8) {
DownsampledKFImage(url: URL(string: creatorProfileImageUrl ?? ""), size: CGSize(width: 32, height: 32))
.background(Color.gray800)
.clipShape(Circle())
Text(creatorNickname)
.appFont(.body5)
.foregroundColor(.white)
.lineLimit(1)
Spacer(minLength: 0)
}
}
private var imageContent: some View {
ZStack {
DownsampledKFImage(url: URL(string: imageUrl ?? ""), size: CGSize(width: 240, height: 150))
.background(Color.gray800)
.frame(maxWidth: .infinity)
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s12, style: .continuous))
.blur(radius: isLocked ? 8 : 0)
if isLocked {
VStack(spacing: SodaSpacing.s6) {
Image("ic_new_community_lock")
.resizable()
.renderingMode(.template)
.foregroundColor(.white)
.frame(width: 24, height: 24)
if let price {
Text("\(price) can")
.appFont(.caption2)
.foregroundColor(Color.button)
.padding(.horizontal, SodaSpacing.s12)
.padding(.vertical, SodaSpacing.s6)
.overlay(
Capsule()
.stroke(Color.button, lineWidth: 1)
)
}
}
}
}
}
private var footer: some View {
HStack(spacing: SodaSpacing.s12) {
if let createdAt, !createdAt.isEmpty {
Text(createdAt)
.appFont(.caption2)
.foregroundColor(Color.gray500)
}
if let likeCount {
Text("Like \(likeCount)")
.appFont(.caption2)
.foregroundColor(Color.gray500)
}
if let commentCount {
Text("Comment \(commentCount)")
.appFont(.caption2)
.foregroundColor(Color.gray500)
}
}
}
private var hasImage: Bool {
!(imageUrl ?? "").isEmpty
}
private var isLocked: Bool {
(price ?? 0) > 0 && !existOrdered
}
}
struct CommunityPostCard_Previews: PreviewProvider {
static var previews: some View {
CommunityPostCard(
creatorNickname: "크리에이터",
creatorProfileImageUrl: nil,
content: "커뮤니티 본문입니다.",
imageUrl: nil,
price: nil,
existOrdered: false,
createdAt: "방금 전",
likeCount: 10,
commentCount: 2
)
.padding(SodaSpacing.s20)
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}