From f6ae14d614ecffaa9516d1612b54000032f4e634 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Fri, 8 Nov 2024 21:06:24 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20-=20=EC=86=8C=EC=9E=A5=EB=A7=8C,=20=EB=8C=80?= =?UTF-8?q?=EC=97=AC=EB=A7=8C=20=EA=B0=80=EB=8A=A5=EC=8B=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=EB=B0=B0?= =?UTF-8?q?=EA=B2=BD=EC=83=89=20=EB=B3=80=EA=B2=BD=20-=20=EC=86=8C?= =?UTF-8?q?=EC=9E=A5=EB=A7=8C,=20=EB=8C=80=EC=97=AC=EB=A7=8C=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=EC=8B=9C=20=EA=B5=AC=EB=A7=A4=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=EC=9D=84=20=ED=84=B0=EC=B9=98=ED=95=98?= =?UTF-8?q?=EB=A9=B4=20=EB=B0=94=EB=A1=9C=20=EA=B5=AC=EB=A7=A4=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detail/ContentDetailPurchaseButton.swift | 7 +- .../Content/Detail/ContentDetailView.swift | 27 ++++-- .../ContentOrderConfirmDialogView.swift | 46 +++++----- .../Detail/ContentOrderDialogView.swift | 85 +++++++++---------- .../GetAudioContentDetailResponse.swift | 2 +- 5 files changed, 87 insertions(+), 80 deletions(-) diff --git a/SodaLive/Sources/Content/Detail/ContentDetailPurchaseButton.swift b/SodaLive/Sources/Content/Detail/ContentDetailPurchaseButton.swift index 5e7e23a..52beca6 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailPurchaseButton.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailPurchaseButton.swift @@ -10,7 +10,8 @@ import SwiftUI struct ContentDetailPurchaseButton: View { let price: Int - let isOnlyRental: Bool + let title: String + let backgroundColor: Color var body: some View { HStack(spacing: 0) { @@ -29,13 +30,13 @@ struct ContentDetailPurchaseButton: View { .font(.custom(Font.light.rawValue, size: 12)) .foregroundColor(.white) - Text(isOnlyRental ? " 대여하기" : " 구매하기") + Text(title) .font(.custom(Font.bold.rawValue, size: 14.7)) .foregroundColor(.white) } .frame(maxWidth: .infinity) .frame(height: 48.7) - .background(Color.button) + .background(backgroundColor) .cornerRadius(5.3) .padding(.top, 18.3) } diff --git a/SodaLive/Sources/Content/Detail/ContentDetailView.swift b/SodaLive/Sources/Content/Detail/ContentDetailView.swift index 2928c06..c12c6ef 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailView.swift @@ -123,13 +123,23 @@ struct ContentDetailView: View { .padding(.top, 18.3) .padding(.horizontal, 13.3) } else { - ContentDetailPurchaseButton(price: audioContent.price, isOnlyRental: audioContent.isOnlyRental) + ContentDetailPurchaseButton( + price: audioContent.price, + title: audioContent.purchaseOption == .RENT_ONLY ? " 대여하기" : + audioContent.purchaseOption == .BUY_ONLY ? " 소장하기" : " 구매하기", + backgroundColor: audioContent.purchaseOption == .RENT_ONLY ? Color(hex: "548f7d") : + audioContent.purchaseOption == .BUY_ONLY ? Color(hex: "59548f") : + Color.button + ) .contentShape(Rectangle()) .padding(.horizontal, 13.3) .onTapGesture { - if let _ = audioContent.totalContentCount, let _ = audioContent.remainingContentCount { + if audioContent.purchaseOption == .BUY_ONLY || (audioContent.totalContentCount != nil && audioContent.remainingContentCount != nil) { viewModel.orderType = .KEEP isShowOrderConfirmView = true + } else if audioContent.purchaseOption == .RENT_ONLY { + viewModel.orderType = .RENTAL + isShowOrderConfirmView = true } else { isShowOrderView = true } @@ -204,7 +214,6 @@ struct ContentDetailView: View { ContentOrderDialogView( isShowing: $isShowOrderView, price: audioContent.price, - isOnlyRental: audioContent.isOnlyRental, onTapPurchase: { viewModel.orderType = $0 isShowOrderConfirmView = true @@ -228,9 +237,14 @@ struct ContentDetailView: View { VStack(spacing: 0) { ContentOrderConfirmDialogView( isShowing: $isShowOrderConfirmView, - audioContent: audioContent, + title: audioContent.title, + price: audioContent.purchaseOption == .BOTH && orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.7)) : audioContent.price, + duration: audioContent.duration, + themeStr: audioContent.themeStr, + coverImageUrl: audioContent.coverImageUrl, + creatorNickname: audioContent.creator.nickname, + creatorProfileImageUrl: audioContent.creator.profileImageUrl, orderType: orderType, - isOnlyRental: audioContent.isOnlyRental, onClickConfirm: { if UserDefaults.int(forKey: .userId) == 17958 { AppState.shared @@ -239,7 +253,8 @@ struct ContentDetailView: View { orderType: orderType, contentId: audioContent.contentId, title: audioContent.title, - can: !audioContent.isOnlyRental && orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.7)) : audioContent.price + can: audioContent.purchaseOption == .BOTH && orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.7)) : + audioContent.price ) ) } else { diff --git a/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift b/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift index 1be221d..33805af 100644 --- a/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift +++ b/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift @@ -12,9 +12,15 @@ struct ContentOrderConfirmDialogView: View { @Binding var isShowing: Bool - let audioContent: GetAudioContentDetailResponse + let title: String + let price: Int + let duration: String + let themeStr: String + let coverImageUrl: String + let creatorNickname: String + let creatorProfileImageUrl: String + let orderType: OrderType - let isOnlyRental: Bool let onClickConfirm: () -> Void var body: some View { @@ -31,7 +37,7 @@ struct ContentOrderConfirmDialogView: View { HStack(spacing: 11) { ZStack(alignment: .topLeading) { - KFImage(URL(string: audioContent.coverImageUrl)) + KFImage(URL(string: coverImageUrl)) .cancelOnDisappear(true) .downsampling( size: CGSize( @@ -46,20 +52,20 @@ struct ContentOrderConfirmDialogView: View { } VStack(alignment: .leading, spacing: 0) { - Text(audioContent.themeStr) + Text(themeStr) .font(.custom(Font.medium.rawValue, size: 8)) .foregroundColor(Color(hex: "3bac6a")) .padding(2.3) .background(Color(hex: "28312b")) .cornerRadius(2) - Text(audioContent.title) + Text(title) .font(.custom(Font.bold.rawValue, size: 11.3)) .foregroundColor(Color.grayd2) .padding(.top, 2) HStack(spacing: 4.3) { - KFImage(URL(string: audioContent.creator.profileImageUrl)) + KFImage(URL(string: creatorProfileImageUrl)) .cancelOnDisappear(true) .downsampling( size: CGSize( @@ -71,13 +77,13 @@ struct ContentOrderConfirmDialogView: View { .frame(width: 13.3, height: 13.3) .clipShape(Circle()) - Text(audioContent.creator.nickname) + Text(creatorNickname) .font(.custom(Font.medium.rawValue, size: 10)) .foregroundColor(Color.gray77) } .padding(.top, 6.7) - Text(audioContent.duration) + Text(duration) .font(.custom(Font.medium.rawValue, size: 11)) .foregroundColor(Color.gray77) .padding(.top, 6.7) @@ -114,25 +120,13 @@ struct ContentOrderConfirmDialogView: View { .resizable() .frame(width: 16.7, height: 16.7) - if orderType == .RENTAL { - Text("\(isOnlyRental ? audioContent.price : Int(ceil(Double(audioContent.price) * 0.7)))") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } else { - Text("\(audioContent.price)") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } + Text("\(price)") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) } else { - if orderType == .RENTAL { - Text("\(isOnlyRental ? audioContent.price * 110 : Int(ceil(Double(audioContent.price) * 0.7)) * 110)원") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } else { - Text("\(audioContent.price * 110)원") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } + Text("\(price * 110)원") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) } Spacer() diff --git a/SodaLive/Sources/Content/Detail/ContentOrderDialogView.swift b/SodaLive/Sources/Content/Detail/ContentOrderDialogView.swift index 6673d3c..0621ea2 100644 --- a/SodaLive/Sources/Content/Detail/ContentOrderDialogView.swift +++ b/SodaLive/Sources/Content/Detail/ContentOrderDialogView.swift @@ -12,7 +12,6 @@ struct ContentOrderDialogView: View { @Binding var isShowing: Bool let price: Int - let isOnlyRental: Bool let onTapPurchase: (OrderType) -> Void var body: some View { @@ -47,11 +46,11 @@ struct ContentOrderDialogView: View { } if UserDefaults.int(forKey: .userId) == 17958 { - Text(isOnlyRental ? "\(price * 110)" : "\(Int(ceil(Double(price) * 0.7)) * 110)") + Text("\(Int(ceil(Double(price) * 0.7)) * 110)") .font(.custom(Font.bold.rawValue, size: 13.3)) .foregroundColor(Color.grayee) } else { - Text(isOnlyRental ? "\(price)" : "\(Int(ceil(Double(price) * 0.7)))") + Text("\(Int(ceil(Double(price) * 0.7)))") .font(.custom(Font.bold.rawValue, size: 13.3)) .foregroundColor(Color.grayee) } @@ -72,52 +71,50 @@ struct ContentOrderDialogView: View { } } - if !isOnlyRental { - HStack(spacing: 0) { - VStack(alignment: .leading, spacing: 5.3) { - Text("소장") + HStack(spacing: 0) { + VStack(alignment: .leading, spacing: 5.3) { + Text("소장") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(.white) + + Text("(서비스 종료시까지)") + .font(.custom(Font.light.rawValue, size: 12)) + .foregroundColor(.white) + } + + Spacer() + + HStack(spacing: 8) { + if UserDefaults.int(forKey: .userId) != 17958 { + Image("ic_can") + .resizable() + .frame(width: 16.7, height: 16.7) + } + + if UserDefaults.int(forKey: .userId) == 17958 { + Text("\(price * 110)") .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(.white) - - Text("(서비스 종료시까지)") - .font(.custom(Font.light.rawValue, size: 12)) - .foregroundColor(.white) + .foregroundColor(Color.grayee) + } else { + Text("\(price)") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) } - Spacer() - - HStack(spacing: 8) { - if UserDefaults.int(forKey: .userId) != 17958 { - Image("ic_can") - .resizable() - .frame(width: 16.7, height: 16.7) - } - - if UserDefaults.int(forKey: .userId) == 17958 { - Text("\(price * 110)") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } else { - Text("\(price)") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } - - if UserDefaults.int(forKey: .userId) == 17958 { - Text("원") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) - } - } - .padding(.vertical, 8) - .padding(.horizontal, 13.3) - .background(Color.button) - .cornerRadius(5.3) - .onTapGesture { - onTapPurchase(.KEEP) - isShowing = false + if UserDefaults.int(forKey: .userId) == 17958 { + Text("원") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) } } + .padding(.vertical, 8) + .padding(.horizontal, 13.3) + .background(Color.button) + .cornerRadius(5.3) + .onTapGesture { + onTapPurchase(.KEEP) + isShowing = false + } } } .padding(24) diff --git a/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift b/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift index 36c2e8a..7a87de2 100644 --- a/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift +++ b/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift @@ -24,8 +24,8 @@ struct GetAudioContentDetailResponse: Decodable { let isActivePreview: Bool let isAdult: Bool let isMosaic: Bool - let isOnlyRental: Bool let existOrdered: Bool + let purchaseOption: PurchaseOption let orderType: OrderType? let remainingTime: String? let creatorOtherContentList: [OtherContentResponse]