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,65 @@
import SwiftUI
struct CreatorProfileItem: View {
let imageUrl: String?
let name: String
let subtitle: String?
let action: (() -> Void)?
init(
imageUrl: String?,
name: String,
subtitle: String? = nil,
action: (() -> Void)? = nil
) {
self.imageUrl = imageUrl
self.name = name
self.subtitle = subtitle
self.action = action
}
var body: some View {
Button {
action?()
} label: {
VStack(alignment: .center, spacing: SodaSpacing.s8) {
profileImage
VStack(alignment: .center, spacing: 2) {
Text(name)
.appFont(.body4)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
if let subtitle, !subtitle.isEmpty {
Text(subtitle)
.appFont(.caption2)
.foregroundColor(Color.gray500)
.lineLimit(1)
.truncationMode(.tail)
}
}
}
.frame(maxWidth: .infinity)
}
.buttonStyle(.plain)
.disabled(action == nil)
}
private var profileImage: some View {
DownsampledKFImage(url: URL(string: imageUrl ?? ""), size: CGSize(width: 72, height: 72))
.background(Color.gray800)
.clipShape(Circle())
}
}
struct CreatorProfileItem_Previews: PreviewProvider {
static var previews: some View {
CreatorProfileItem(imageUrl: nil, name: "크리에이터", subtitle: "방금 활동")
.frame(width: 96)
.padding(SodaSpacing.s20)
.background(Color.black)
.previewLayout(.sizeThatFits)
}
}