Files
sodalive-ios/SodaLive/Sources/Content/ContentItemView.swift
Yu Sung 8221746569 feat(image): 메인 홈, 채팅 - 톡 페이지에 DownsampledKFImage 적용
- 수평 리스트 HStack → LazyHStack으로 교체해 프리로딩/메모리 개선
2025-10-23 18:55:53 +09:00

78 lines
2.4 KiB
Swift

//
// ContentItemView.swift
// SodaLive
//
// Created by klaus on 7/10/25.
//
import SwiftUI
import Kingfisher
struct ContentItemView: View {
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
let item: AudioContentMainItem
var body: some View {
VStack(alignment: .leading, spacing: 0) {
ZStack(alignment: .top) {
DownsampledKFImage(
url: URL(string: item.coverImageUrl),
size: CGSize(width: 160, height: 160)
)
.cornerRadius(16)
HStack(alignment: .top, spacing: 0) {
Spacer()
if item.isPointAvailable {
Image("ic_point")
.padding(.top, 6)
.padding(.trailing, 6)
}
}
}
Text(item.title)
.font(.custom(Font.preRegular.rawValue, size: 18))
.foregroundColor(.white)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.lineLimit(1)
.padding(.horizontal, 6)
.padding(.top, 8)
Text(item.creatorNickname)
.font(.custom(Font.preRegular.rawValue, size: 14))
.foregroundColor(Color(hex: "78909C"))
.lineLimit(1)
.padding(.horizontal, 6)
.padding(.top, 4)
}
.frame(width: 160)
.onTapGesture {
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .contentDetail(contentId: item.contentId))
} else {
AppState.shared
.setAppStep(step: .login)
}
}
}
}
#Preview {
ContentItemView(
item: AudioContentMainItem(
contentId: 1,
creatorId: 1,
title: "동정개발일지",
coverImageUrl: "https://cf.sodalive.net/audio_content_cover/5696/5696-cover-50066e61-6633-445b-9ae1-3749554d3f08-9514-1750756003835",
creatorNickname: "오늘밤결제했습니다",
isPointAvailable: true
)
)
}