// // LiveReservationStatusItemView.swift // SodaLive // // Created by klaus on 2023/08/11. // import SwiftUI import Kingfisher struct LiveReservationStatusItemView: View { let item: GetLiveReservationResponse var body: some View { HStack(spacing: 0) { KFImage(URL(string: item.coverImageUrl)) .cancelOnDisappear(true) .downsampling( size: CGSize( width: 80, height: 116.7 ) ) .resizable() .scaledToFill() .frame(width: 80, height: 116.7, alignment: .top) .clipped() .cornerRadius(4.7) VStack(alignment: .leading, spacing: 0) { let beginDateText = item.beginDateTimeUtc .parseUtcIsoDate()? .convertDateFormat(dateFormat: "yyyy.MM.dd EEE hh:mm a") ?? item.beginDateTimeUtc Text(beginDateText) .appFont(size: 9.3, weight: .medium) .foregroundColor(Color(hex: "ffd300")) Text(item.masterNickname) .appFont(size: 11.3, weight: .medium) .foregroundColor(Color(hex: "bbbbbb")) .padding(.top, 10) Text(item.title) .appFont(size: 15.3, weight: .medium) .foregroundColor(Color(hex: "e2e2e2")) .lineLimit(2) .padding(.top, 4.3) HStack(spacing: 0) { Text( item.price > 0 ? "\(item.price)캔" : "무료" ) .appFont(size: 12, weight: .medium) .foregroundColor(Color(hex: "e2e2e2").opacity(0.4)) Spacer() if !item.cancelable { Text("예약 취소 불가") .appFont(size: 10.7, weight: .light) .foregroundColor(Color(hex: "777777")) } } .padding(.top, 15.3) } .padding(.leading, 20) .padding(.trailing, 16.3) if item.cancelable { Spacer() Text("예약\n취소") .appFont(size: 12, weight: .bold) .foregroundColor(Color(hex: "9970ff")) .padding(10.7) .overlay( RoundedRectangle(cornerRadius: 6.7) .stroke( Color(hex: "9970ff"), lineWidth: 1 ) ) .onTapGesture { AppState.shared.setAppStep( step: .liveReservationCancel(reservationId: item.reservationId) ) } } } .padding(13.3) .background(Color.black) } } struct LiveReservationStatusItemView_Previews: PreviewProvider { static var previews: some View { LiveReservationStatusItemView( item: GetLiveReservationResponse( reservationId: 0, roomId: 1, title: "여자들이 좋아하는 남자 스타일은??여자들이 좋아하는 남자 스타일은??여자들이 좋아하는 남자 스타일은??", coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png", price: 0, masterNickname: "사냥꾼1004", beginDateTimeUtc: "2021-05-20T22:00:00", cancelable: false ) ) } }