feat(home): AI 캐릭터 섹션을 연결한다
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainHomeAiCharacterSection: View {
|
||||
let items: [HomeAiCharacterItem]
|
||||
let onTapCharacter: (Int) -> Void
|
||||
|
||||
init(
|
||||
items: [HomeAiCharacterItem],
|
||||
onTapCharacter: @escaping (Int) -> Void = { _ in }
|
||||
) {
|
||||
self.items = items
|
||||
self.onTapCharacter = onTapCharacter
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if !items.isEmpty {
|
||||
VStack(alignment: .leading, spacing: SodaSpacing.s14) {
|
||||
SectionTitle(title: I18n.HomeRecommendation.aiCharacterSectionTitle)
|
||||
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHStack(alignment: .center, spacing: SodaSpacing.s4) {
|
||||
ForEach(items, id: \.self) { item in
|
||||
Button {
|
||||
onTapCharacter(item.characterId)
|
||||
} label: {
|
||||
AiCharacterCard(
|
||||
name: item.name,
|
||||
description: item.description,
|
||||
profileImageUrl: item.profileImage,
|
||||
chatCount: item.totalChatCount,
|
||||
originalTitle: item.originalWorkTitle
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, SodaSpacing.s14)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MainHomeAiCharacterSection_Previews: PreviewProvider {
|
||||
private static let previewImageUrl = "https://picsum.photos/500/500"
|
||||
|
||||
static var previews: some View {
|
||||
MainHomeAiCharacterSection(
|
||||
items: [
|
||||
HomeAiCharacterItem(
|
||||
characterId: 1,
|
||||
creatorId: 10,
|
||||
name: "캐릭터 이름",
|
||||
description: "캐릭터 소개가 들어가는 부분입니다 넘어가는 경우 ...처리",
|
||||
profileImage: previewImageUrl,
|
||||
totalChatCount: 14_000,
|
||||
originalWorkTitle: nil
|
||||
),
|
||||
HomeAiCharacterItem(
|
||||
characterId: 2,
|
||||
creatorId: 11,
|
||||
name: "캐릭터 이름",
|
||||
description: "캐릭터 소개가 들어가는 부분입니다 넘어가는 경우 ...처리",
|
||||
profileImage: previewImageUrl,
|
||||
totalChatCount: 128,
|
||||
originalWorkTitle: "작품 이름"
|
||||
)
|
||||
]
|
||||
)
|
||||
.padding(.vertical, SodaSpacing.s20)
|
||||
.background(Color.black)
|
||||
.previewLayout(.sizeThatFits)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user