Files
sodalive-ios/SodaLive/Sources/Chat/Character/CharacterSectionView.swift
Yu Sung 62012bd722 feat(image): DownsampledKFImage 추가 및 캐릭터/배너에 공통 적용
- KFImage 공통 옵션(다운샘플링, scaleFactor, backgroundDecode,
  cancelOnDisappear, retry) 캡슐화한 DownsampledKFImage 추가
- 채팅-캐릭터 탭 Character/Recent/배너 뷰에서 인라인 KFImage 제거 → 공통 뷰 적용
- 수평 리스트 HStack → LazyHStack으로 교체해 프리로딩/메모리 개선

Why: 대형 원본 디코딩으로 인한 메모리 스파이크 완화 및 일관된
이미지 로딩 정책 적용. 유지보수성 및 성능 향상.
2025-10-23 17:10:04 +09:00

65 lines
2.0 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 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)
}