Files
sodalive-ios/SodaLive/Sources/Chat/Character/CharacterSectionView.swift
2025-09-11 21:23:46 +09:00

54 lines
1.6 KiB
Swift

//
// CharacterSectionView.swift
// SodaLive
//
// Created by klaus on 8/29/25.
//
import SwiftUI
struct CharacterSectionView: View {
let title: String
let items: [Character]
let isShowRank: Bool
var onTap: (Character) -> Void = { _ in }
var body: some View {
VStack(alignment: .leading, spacing: 16) {
Text(title)
.font(.custom(Font.preBold.rawValue, size: 20))
.foregroundColor(.white)
.padding(.horizontal, 24)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(items.indices, id: \.self) { idx in
let item = items[idx]
CharacterItemView(
character: item,
size: screenSize().width * 0.42,
rank: idx + 1,
isShowRank: isShowRank
)
.onTapGesture { onTap(item) }
}
}
.padding(.horizontal, 24)
}
}
}
}
#Preview {
CharacterSectionView(
title: "신규 캐릭터",
items: [
Character(characterId: 1, name: "찰리", description: "새로운 친구", imageUrl: "https://picsum.photos/300"),
Character(characterId: 2, name: "데이지", description: "", imageUrl: "https://picsum.photos/300")
],
isShowRank: true
)
.padding()
.background(Color.black)
}