Files
sodalive-ios/SodaLive/Sources/Live/Now/All/LiveNowAllItemView.swift

131 lines
3.9 KiB
Swift

//
// LiveNowAllItemView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import Kingfisher
struct LiveNowAllItemView: View {
let item: GetRoomListResponse
let itemWidth: CGFloat
var body: some View {
HStack(alignment: .center, spacing: 14) {
KFImage(URL(string: item.creatorProfileImage))
.cancelOnDisappear(true)
.downsampling(size: CGSize(width: 75, height: 75))
.resizable()
.scaledToFill()
.frame(width: 75, height: 75)
.clipShape(Circle())
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 8) {
liveTag
Text(startTimeText)
.appFont(size: 14, weight: .regular)
.foregroundColor(Color.gray500)
}
Text(item.title)
.appFont(size: 18, weight: .bold)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
Text(item.creatorNickname)
.appFont(size: 14, weight: .regular)
.foregroundColor(Color.gray500)
.lineLimit(1)
.truncationMode(.tail)
}
.frame(maxWidth: .infinity, alignment: .leading)
priceView
}
.frame(width: itemWidth, height: 99)
}
private var liveTag: some View {
HStack(spacing: 4) {
Circle()
.fill(Color.red400)
.frame(width: 8, height: 8)
Text("LIVE")
.appFont(size: 12, weight: .regular)
.foregroundColor(.white)
}
.padding(.horizontal, 4)
.padding(.vertical, 2)
.frame(height: 18)
.background(Color.black)
.clipShape(Capsule())
}
@ViewBuilder
private var priceView: some View {
if item.price > 0 {
HStack(spacing: 2) {
Image("ic_bar_cash")
.resizable()
.scaledToFit()
.frame(width: 18, height: 18)
Text("\(item.price)")
.appFont(size: 14, weight: .regular)
.foregroundColor(.white)
.lineLimit(1)
}
.padding(.trailing, 7)
.frame(width: 60, alignment: .trailing)
} else {
Text(I18n.CreateContent.free)
.appFont(size: 14, weight: .regular)
.foregroundColor(.white)
.lineLimit(1)
.padding(.trailing, 7)
.frame(width: 60, alignment: .trailing)
}
}
private var startTimeText: String {
guard let date = DateParser.parse(item.beginDateTimeUtc) else {
return item.beginDateTimeUtc
}
return date.convertDateFormat(dateFormat: "HH:mm")
}
}
struct LiveNowAllItemView_Previews: PreviewProvider {
static var previews: some View {
LiveNowAllItemView(
item: GetRoomListResponse(
roomId: 99,
title: "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
content: "testtest",
beginDateTimeUtc: "2025-08-10T15:00:00",
numberOfParticipate: 3,
numberOfPeople: 5,
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
isAdult: true,
price: 20,
tags: ["fanmeeting", "healing"],
channelName: nil,
creatorProfileImage: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "user8",
creatorId: 19,
isReservation: false,
isPrivateRoom: true
),
itemWidth: 102
)
}
}