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

72 lines
2.3 KiB
Swift

//
// RecommendChannelContentItemView.swift
// SodaLive
//
// Created by klaus on 7/14/25.
//
import SwiftUI
import Kingfisher
struct RecommendChannelContentItemView: View {
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
let item: RecommendChannelContentItem
var body: some View {
HStack(spacing: 16) {
DownsampledKFImage(
url: URL(string: item.thumbnailImageUrl),
size: CGSize(width: 60, height: 60)
)
.cornerRadius(12)
VStack(alignment: .leading, spacing: 2) {
Text(item.title)
.font(.custom(Font.preRegular.rawValue, size: 18))
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
HStack(spacing: 12) {
HStack(spacing: 4) {
Image("ic_heart_white")
Text("\(item.likeCount)")
.font(.custom(Font.preRegular.rawValue, size: 18))
.foregroundColor(.white)
}
HStack(spacing: 4) {
Image("ic_comment_white")
Text("\(item.commentCount)")
.font(.custom(Font.preRegular.rawValue, size: 18))
.foregroundColor(.white)
}
}
}
}
.onTapGesture {
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .contentDetail(contentId: item.contentId))
} else {
AppState.shared.setAppStep(step: .login)
}
}
}
}
#Preview {
RecommendChannelContentItemView(
item: RecommendChannelContentItem(
contentId: 1,
title: "고품격 음악 밥솥",
thumbnailImageUrl: "https://cf.sodalive.net/audio_content_cover/5819/5819-cover-20a26c55-c7a2-47ef-bca5-ce47d953dfe0-1373-1752293900615",
likeCount: 999,
commentCount: 99
)
)
}