콘텐츠 상세 - 대여만 가능한 콘텐츠의 경우 소장 버튼이 보이지 않고 가격의 100%가 보이도록 수정
This commit is contained in:
parent
115a30a7b6
commit
995c6adab7
|
@ -10,6 +10,7 @@ import SwiftUI
|
||||||
struct ContentDetailPurchaseButton: View {
|
struct ContentDetailPurchaseButton: View {
|
||||||
|
|
||||||
let price: Int
|
let price: Int
|
||||||
|
let isOnlyRental: Bool
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
|
@ -26,7 +27,7 @@ struct ContentDetailPurchaseButton: View {
|
||||||
.font(.custom(Font.light.rawValue, size: 12))
|
.font(.custom(Font.light.rawValue, size: 12))
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
|
|
||||||
Text(" 구매하기")
|
Text(isOnlyRental ? " 대여하기" : " 구매하기")
|
||||||
.font(.custom(Font.bold.rawValue, size: 14.7))
|
.font(.custom(Font.bold.rawValue, size: 14.7))
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct ContentDetailView: View {
|
||||||
!audioContent.existOrdered &&
|
!audioContent.existOrdered &&
|
||||||
audioContent.orderType == nil &&
|
audioContent.orderType == nil &&
|
||||||
audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) {
|
audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) {
|
||||||
ContentDetailPurchaseButton(price: audioContent.price)
|
ContentDetailPurchaseButton(price: audioContent.price, isOnlyRental: audioContent.isOnlyRental)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.padding(.horizontal, 13.3)
|
.padding(.horizontal, 13.3)
|
||||||
.onTapGesture { isShowOrderView = true }
|
.onTapGesture { isShowOrderView = true }
|
||||||
|
@ -161,6 +161,7 @@ struct ContentDetailView: View {
|
||||||
ContentOrderDialogView(
|
ContentOrderDialogView(
|
||||||
isShowing: $isShowOrderView,
|
isShowing: $isShowOrderView,
|
||||||
price: audioContent.price,
|
price: audioContent.price,
|
||||||
|
isOnlyRental: audioContent.isOnlyRental,
|
||||||
onTapPurchase: {
|
onTapPurchase: {
|
||||||
viewModel.orderType = $0
|
viewModel.orderType = $0
|
||||||
isShowOrderConfirmView = true
|
isShowOrderConfirmView = true
|
||||||
|
@ -186,6 +187,7 @@ struct ContentDetailView: View {
|
||||||
isShowing: $isShowOrderConfirmView,
|
isShowing: $isShowOrderConfirmView,
|
||||||
audioContent: audioContent,
|
audioContent: audioContent,
|
||||||
orderType: orderType,
|
orderType: orderType,
|
||||||
|
isOnlyRental: audioContent.isOnlyRental,
|
||||||
onClickConfirm: {
|
onClickConfirm: {
|
||||||
viewModel.order(orderType: orderType)
|
viewModel.order(orderType: orderType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,7 +298,7 @@ final class ContentDetailViewModel: ObservableObject {
|
||||||
|
|
||||||
if decoded.success {
|
if decoded.success {
|
||||||
self.orderType = nil
|
self.orderType = nil
|
||||||
self.errorMessage = "구매가 완료되었습니다."
|
self.errorMessage = orderType == .RENTAL ? "대여가 완료되었습니다." : "구매가 완료되었습니다."
|
||||||
self.isShowPopup = true
|
self.isShowPopup = true
|
||||||
self.getAudioContentDetail()
|
self.getAudioContentDetail()
|
||||||
ContentPlayManager.shared.conditionalStopAudio(contentId: contentId)
|
ContentPlayManager.shared.conditionalStopAudio(contentId: contentId)
|
||||||
|
|
|
@ -14,6 +14,7 @@ struct ContentOrderConfirmDialogView: View {
|
||||||
|
|
||||||
let audioContent: GetAudioContentDetailResponse
|
let audioContent: GetAudioContentDetailResponse
|
||||||
let orderType: OrderType
|
let orderType: OrderType
|
||||||
|
let isOnlyRental: Bool
|
||||||
let onClickConfirm: () -> Void
|
let onClickConfirm: () -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -90,9 +91,15 @@ struct ContentOrderConfirmDialogView: View {
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 16.7, height: 16.7)
|
.frame(width: 16.7, height: 16.7)
|
||||||
|
|
||||||
Text("\(orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.6)) : audioContent.price)")
|
if orderType == .RENTAL {
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
Text("\(isOnlyRental ? audioContent.price : Int(ceil(Double(audioContent.price) * 0.6)))")
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
|
.foregroundColor(Color(hex: "eeeeee"))
|
||||||
|
} else {
|
||||||
|
Text("\(audioContent.price)")
|
||||||
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
|
.foregroundColor(Color(hex: "eeeeee"))
|
||||||
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ struct ContentOrderDialogView: View {
|
||||||
@Binding var isShowing: Bool
|
@Binding var isShowing: Bool
|
||||||
|
|
||||||
let price: Int
|
let price: Int
|
||||||
|
let isOnlyRental: Bool
|
||||||
let onTapPurchase: (OrderType) -> Void
|
let onTapPurchase: (OrderType) -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -31,7 +32,7 @@ struct ContentOrderDialogView: View {
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
|
|
||||||
Text("(이용기간 7일)")
|
Text("(이용기간 15일)")
|
||||||
.font(.custom(Font.light.rawValue, size: 12))
|
.font(.custom(Font.light.rawValue, size: 12))
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +44,7 @@ struct ContentOrderDialogView: View {
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 16.7, height: 16.7)
|
.frame(width: 16.7, height: 16.7)
|
||||||
|
|
||||||
Text("\(Int(ceil(Double(price) * 0.6)))")
|
Text(isOnlyRental ? "\(price)" : "\(Int(ceil(Double(price) * 0.6)))")
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color(hex: "eeeeee"))
|
||||||
}
|
}
|
||||||
|
@ -57,35 +58,37 @@ struct ContentOrderDialogView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack(spacing: 0) {
|
if !isOnlyRental {
|
||||||
VStack(alignment: .leading, spacing: 5.3) {
|
HStack(spacing: 0) {
|
||||||
Text("소장")
|
VStack(alignment: .leading, spacing: 5.3) {
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
Text("소장")
|
||||||
.foregroundColor(.white)
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
|
.foregroundColor(.white)
|
||||||
|
|
||||||
Text("(서비스 종료시까지)")
|
Text("(서비스 종료시까지)")
|
||||||
.font(.custom(Font.light.rawValue, size: 12))
|
.font(.custom(Font.light.rawValue, size: 12))
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
Image("ic_can")
|
Image("ic_can")
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 16.7, height: 16.7)
|
.frame(width: 16.7, height: 16.7)
|
||||||
|
|
||||||
Text("\(price)")
|
Text("\(price)")
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color(hex: "eeeeee"))
|
||||||
}
|
}
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
.padding(.horizontal, 13.3)
|
.padding(.horizontal, 13.3)
|
||||||
.background(Color(hex: "9970ff"))
|
.background(Color(hex: "9970ff"))
|
||||||
.cornerRadius(5.3)
|
.cornerRadius(5.3)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
onTapPurchase(.KEEP)
|
onTapPurchase(.KEEP)
|
||||||
isShowing = false
|
isShowing = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct GetAudioContentDetailResponse: Decodable {
|
||||||
let duration: String
|
let duration: String
|
||||||
let isAdult: Bool
|
let isAdult: Bool
|
||||||
let isMosaic: Bool
|
let isMosaic: Bool
|
||||||
|
let isOnlyRental: Bool
|
||||||
let existOrdered: Bool
|
let existOrdered: Bool
|
||||||
let orderType: OrderType?
|
let orderType: OrderType?
|
||||||
let remainingTime: String?
|
let remainingTime: String?
|
||||||
|
|
Loading…
Reference in New Issue