feat(character): 캐릭터 메인 화면 구현 및 Combine 기반 리팩터링
- 배너/최근/신규/큐레이션 섹션 UI 구성 및 데이터 바인딩 - 네트워크 이미지 로더를 Kingfisher(KFImage)로 교체하여 캐싱/재시도 지원 - CharacterApi에 토큰 헤더 포함, GET /api/chat/character/main 연동
This commit is contained in:
49
SodaLive/Sources/Chat/Character/CharacterSectionView.swift
Normal file
49
SodaLive/Sources/Chat/Character/CharacterSectionView.swift
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// CharacterSectionView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 8/29/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CharacterSectionView: View {
|
||||
let title: String
|
||||
let items: [Character]
|
||||
var onTap: (Character) -> Void = { _ in }
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
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
|
||||
)
|
||||
.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")
|
||||
]
|
||||
)
|
||||
.padding()
|
||||
.background(Color.black)
|
||||
}
|
||||
Reference in New Issue
Block a user