feat(character): 캐릭터 메인 화면 구현 및 Combine 기반 리팩터링
- 배너/최근/신규/큐레이션 섹션 UI 구성 및 데이터 바인딩 - 네트워크 이미지 로더를 Kingfisher(KFImage)로 교체하여 캐싱/재시도 지원 - CharacterApi에 토큰 헤더 포함, GET /api/chat/character/main 연동
This commit is contained in:
		@@ -0,0 +1,61 @@
 | 
			
		||||
//
 | 
			
		||||
//  AutoSlideCharacterBannerView.swift
 | 
			
		||||
//  SodaLive
 | 
			
		||||
//
 | 
			
		||||
//  Created by klaus on 8/29/25.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
import SwiftUI
 | 
			
		||||
import Kingfisher
 | 
			
		||||
 | 
			
		||||
struct AutoSlideCharacterBannerView: View {
 | 
			
		||||
    var items: [CharacterBannerResponse] = []
 | 
			
		||||
    var onTap: (CharacterBannerResponse) -> Void = { _ in }
 | 
			
		||||
    
 | 
			
		||||
    @State private var index: Int = 0
 | 
			
		||||
    @State private var height: CGFloat = 0
 | 
			
		||||
    private let timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect()
 | 
			
		||||
    
 | 
			
		||||
    var body: some View {
 | 
			
		||||
        TabView(selection: $index) {
 | 
			
		||||
            ForEach(0..<items.count, id: \.self) { index in
 | 
			
		||||
                let item = items[index]
 | 
			
		||||
                KFImage(URL(string: item.imageUrl))
 | 
			
		||||
                    .placeholder { Color.gray.opacity(0.2) }
 | 
			
		||||
                    .retry(maxCount: 2, interval: .seconds(1))
 | 
			
		||||
                    .cancelOnDisappear(true)
 | 
			
		||||
                    .resizable()
 | 
			
		||||
                    .scaledToFill()
 | 
			
		||||
                    .frame(height: height)
 | 
			
		||||
                    .clipped()
 | 
			
		||||
                    .cornerRadius(12)
 | 
			
		||||
                    .contentShape(Rectangle())
 | 
			
		||||
                    .tag(index)
 | 
			
		||||
                    .onTapGesture { onTap(item) }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        .tabViewStyle(.page(indexDisplayMode: .automatic))
 | 
			
		||||
        .frame(maxWidth: .infinity)
 | 
			
		||||
        .frame(height: height)
 | 
			
		||||
        .onAppear {
 | 
			
		||||
            self.height = screenSize().width * 0.53
 | 
			
		||||
        }
 | 
			
		||||
        .onDisappear {
 | 
			
		||||
            timer.upstream.connect().cancel()
 | 
			
		||||
        }
 | 
			
		||||
        .onReceive(timer) { _ in
 | 
			
		||||
            guard !items.isEmpty else { return }
 | 
			
		||||
            withAnimation { index = (index + 1) % items.count }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#Preview {
 | 
			
		||||
    AutoSlideCharacterBannerView(
 | 
			
		||||
        items: [
 | 
			
		||||
            CharacterBannerResponse(characterId: 1, imageUrl: "https://picsum.photos/1000/300")
 | 
			
		||||
        ]
 | 
			
		||||
    )
 | 
			
		||||
    .padding()
 | 
			
		||||
    .background(Color.black)
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
//
 | 
			
		||||
//  CharacterBannerResponse.swift
 | 
			
		||||
//  SodaLive
 | 
			
		||||
//
 | 
			
		||||
//  Created by klaus on 8/29/25.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
struct CharacterBannerResponse: Decodable {
 | 
			
		||||
    let characterId: Int
 | 
			
		||||
    let imageUrl: String
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user