78 lines
2.4 KiB
Swift
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
|
|
)
|
|
)
|
|
}
|