// // 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 trailingTitle: String? = nil var onTapTrailing: (() -> Void)? = nil var onTap: (Character) -> Void = { _ in } var body: some View { VStack(alignment: .leading, spacing: 16) { HStack(spacing: 0) { Text(title) .font(.custom(Font.preBold.rawValue, size: 20)) .foregroundColor(.white) Spacer() if let trailingTitle = trailingTitle { Text(trailingTitle) .font(.custom(Font.preRegular.rawValue, size: 14)) .foregroundColor(Color(hex: "90A4AE")) .onTapGesture { onTapTrailing?() } } } .padding(.horizontal, 24) ScrollView(.horizontal, showsIndicators: false) { LazyHStack(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) }