156 lines
7.1 KiB
Swift
156 lines
7.1 KiB
Swift
//
|
|
// UserProfileLiveView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2023/08/11.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Kingfisher
|
|
|
|
struct UserProfileLiveView: View {
|
|
|
|
let userId: Int
|
|
let liveRoomList: [LiveRoomResponse]
|
|
let onClickParticipant: (LiveRoomResponse) -> Void
|
|
let onClickReservation: (LiveRoomResponse) -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 13.3) {
|
|
ForEach(0..<liveRoomList.count, id: \.self) {
|
|
let item = liveRoomList[$0]
|
|
let dateDic = item.beginDateTimeUtc.parseUtcIsoLocalDateTime()
|
|
HStack(spacing: 16) {
|
|
ZStack(alignment: .topLeading) {
|
|
KFImage(URL(string: item.coverImageUrl))
|
|
.cancelOnDisappear(true)
|
|
.resizable()
|
|
.scaledToFill()
|
|
.frame(width: 107, height: 107, alignment: .top)
|
|
.cornerRadius(16)
|
|
.clipped()
|
|
|
|
if item.isPrivateRoom {
|
|
Image("ic_lock")
|
|
.resizable()
|
|
.frame(width: 20, height: 20)
|
|
.padding(4)
|
|
.background(Color(hex: "333333").opacity(0.7))
|
|
.clipShape(Circle())
|
|
.padding(.leading, 4)
|
|
.padding(.top, 4)
|
|
}
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text(item.managerNickname)
|
|
.font(.custom(Font.preRegular.rawValue, size: 18))
|
|
.foregroundColor(.white)
|
|
.lineLimit(1)
|
|
.truncationMode(.tail)
|
|
|
|
Text(item.title)
|
|
.font(.custom(Font.preRegular.rawValue, size: 14))
|
|
.foregroundColor(Color(hex: "B0BEC5"))
|
|
.lineLimit(1)
|
|
.truncationMode(.tail)
|
|
|
|
HStack(spacing: 4) {
|
|
Text("\(dateDic["dayOfWeek"] ?? "")")
|
|
.font(.custom(Font.preRegular.rawValue, size: 14))
|
|
.foregroundColor(Color(hex: "78909C"))
|
|
|
|
Text("|")
|
|
.font(.custom(Font.preRegular.rawValue, size: 14))
|
|
.foregroundColor(Color(hex: "78909C"))
|
|
|
|
let time = dateDic["time"] ?? ""
|
|
Text("\(item.isActive && !item.channelName.isNullOrBlank() ? "On Air" : time)")
|
|
.font(.custom(Font.preRegular.rawValue, size: 14))
|
|
.foregroundColor(Color(hex: "98A2F6"))
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
|
|
VStack(alignment: .trailing, spacing: 8) {
|
|
if item.isActive && !item.channelName.isNullOrBlank() {
|
|
Text("ON\nAIR")
|
|
.font(.custom(Font.preBold.rawValue, size: 14))
|
|
.foregroundColor(Color.white)
|
|
.frame(width: 52, height: 52)
|
|
.background(Color(hex: "ff5c49"))
|
|
.clipShape(Circle())
|
|
} else {
|
|
VStack(spacing: 0) {
|
|
Text("\(dateDic["month"] ?? "")월")
|
|
.font(.custom(Font.preBold.rawValue, size: 14))
|
|
.foregroundColor(.white)
|
|
.padding(.vertical, 6)
|
|
.frame(maxWidth: .infinity)
|
|
.background(Color(hex: "FF5C49"))
|
|
.cornerRadius(16, corners: [.topLeft, .topRight])
|
|
|
|
Text("\(dateDic["day"] ?? "")")
|
|
.font(.custom(Font.preBold.rawValue, size: 14))
|
|
.foregroundColor(Color(hex: "263238"))
|
|
.padding(.vertical, 6)
|
|
.frame(maxWidth: .infinity)
|
|
.background(Color(hex: "FFFFFF"))
|
|
.cornerRadius(16, corners: [.bottomLeft, .bottomRight])
|
|
}
|
|
}
|
|
|
|
if item.isReservation {
|
|
Text("예약완료")
|
|
.font(.custom(Font.preBold.rawValue, size: 12))
|
|
.foregroundColor(Color.white)
|
|
.padding(4)
|
|
.frame(maxWidth: .infinity)
|
|
.background(Color(hex: "2E6279"))
|
|
.cornerRadius(4)
|
|
} else if item.price > 0 {
|
|
HStack(spacing: 2) {
|
|
Image("ic_can")
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(width: 12)
|
|
|
|
Text("\(item.price)")
|
|
.font(.custom(Font.preRegular.rawValue, size: 12))
|
|
.foregroundColor(.white)
|
|
}
|
|
.padding(4)
|
|
.frame(maxWidth: .infinity)
|
|
.background(Color(hex: "3b5ff1"))
|
|
.cornerRadius(4)
|
|
} else {
|
|
Text("무료")
|
|
.font(.custom(Font.preRegular.rawValue, size: 14))
|
|
.foregroundColor(Color(hex: "#263238"))
|
|
.padding(4)
|
|
.frame(maxWidth: .infinity)
|
|
.background(Color.white)
|
|
.cornerRadius(4)
|
|
}
|
|
}
|
|
.frame(width: 55)
|
|
}
|
|
.padding(10)
|
|
.background(Color(hex: "263238"))
|
|
.cornerRadius(16)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture {
|
|
if item.isActive && !item.channelName.isNullOrBlank() {
|
|
onClickParticipant(item)
|
|
} else {
|
|
if !item.isReservation {
|
|
onClickReservation(item)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|