Files
sodalive-ios/SodaLive/Sources/Live/Now/LiveNowItemView.swift
Yu Sung d9fcdff7a2 feat(image): 메인 라이브 탭에 DownsampledKFImage 적용
- 수평 리스트 HStack → LazyHStack으로 교체해 프리로딩/메모리 개선
2025-10-23 19:03:54 +09:00

127 lines
4.3 KiB
Swift

//
// LiveNowItemView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import Kingfisher
struct LiveNowItemView: View {
let item: GetRoomListResponse
var body: some View {
ZStack(alignment: .top) {
HStack(spacing: 0) {
if item.isPrivateRoom {
Image("ic_lock")
.resizable()
.frame(width: 20, height: 20)
}
Spacer()
}
VStack(spacing: 0) {
ZStack(alignment: .bottom) {
ZStack {
DownsampledKFImage(
url: URL(string: item.creatorProfileImage),
size: CGSize(width: 72, height: 72)
)
.clipShape(Circle())
}
.frame(width: 84, height: 84)
.overlay {
Circle()
.strokeBorder(lineWidth: 3)
.foregroundColor(.button)
}
Image("img_live")
.resizable()
.frame(width: 50, height: 18)
}
Spacer()
Text(item.creatorNickname)
.font(.custom(Font.preRegular.rawValue, size: 16))
.foregroundColor(.white)
.padding(.horizontal, 2)
Text(item.title)
.font(.custom(Font.preRegular.rawValue, size: 12))
.foregroundColor(Color(hex: "#B0BEC5"))
.lineLimit(1)
.truncationMode(.tail)
.padding(.top, 4)
.padding(.horizontal, 2)
Spacer()
if item.price > 0 {
HStack(spacing: 2) {
Image("ic_can")
.resizable()
.scaledToFit()
.frame(width: 16)
Text("\(item.price)")
.font(.custom(Font.preRegular.rawValue, size: 14))
.foregroundColor(.white)
}
.padding(.vertical, 4)
.frame(maxWidth: .infinity)
.background(Color(hex: "3b5ff1"))
.cornerRadius(999)
.padding(.horizontal, 2)
.padding(.bottom, 2)
} else {
Text("무료")
.font(.custom(Font.preRegular.rawValue, size: 14))
.foregroundColor(Color(hex: "#263238"))
.padding(.vertical, 4)
.frame(maxWidth: .infinity)
.background(Color.white)
.cornerRadius(999)
.padding(.horizontal, 2)
.padding(.bottom, 2)
}
}
}
.padding(10)
.frame(width: 144, height: 204, alignment: .top)
.background(Color(hex: "263238"))
.cornerRadius(16)
}
}
struct LiveNowItemView_Previews: PreviewProvider {
static var previews: some View {
LiveNowItemView(
item: GetRoomListResponse(
roomId: 99,
title: "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
content: "testtest",
beginDateTime: "2022.05.23 Mon 03:00 PM",
beginDateTimeUtc: "2025-08-10T15:00:00",
numberOfParticipate: 3,
numberOfPeople: 5,
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
isAdult: true,
price: 0,
tags: ["팬미팅", "힐링"],
channelName: nil,
creatorProfileImage: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "user8",
creatorId: 19,
isReservation: false,
isPrivateRoom: false
)
)
}
}