From 043a583985280cc8095bbe11ee9f73ff334f6680 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 21 May 2024 01:24:27 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=82=AC=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppState.swift | 2 ++ SodaLive/Sources/App/AppStep.swift | 2 +- .../Content/Detail/ContentDetailView.swift | 7 +++---- .../Detail/ContentDetailViewModel.swift | 9 ++++++++- SodaLive/Sources/ContentView.swift | 4 ++-- .../Can/Payment/Temp/CanPaymentTempView.swift | 18 +++++++++++------- SodaLive/Sources/Settings/SettingsView.swift | 9 ++++----- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/SodaLive/Sources/App/AppState.swift b/SodaLive/Sources/App/AppState.swift index a865cc1..5321177 100644 --- a/SodaLive/Sources/App/AppState.swift +++ b/SodaLive/Sources/App/AppState.swift @@ -37,6 +37,8 @@ class AppState: ObservableObject { } @Published var eventPopup: EventItem? = nil + @Published var purchasedContentId = 0 + @Published var purchasedContentOrderType = OrderType.KEEP func setAppStep(step: AppStep) { switch step { diff --git a/SodaLive/Sources/App/AppStep.swift b/SodaLive/Sources/App/AppStep.swift index 9e32f1c..54b5e53 100644 --- a/SodaLive/Sources/App/AppStep.swift +++ b/SodaLive/Sources/App/AppStep.swift @@ -128,5 +128,5 @@ enum AppStep { case seriesContentAll(seriesId: Int, seriesTitle: String) - case tempCanPayment(title: String, can: Int, onSuccess: () -> Void) + case tempCanPayment(orderType: OrderType, contentId: Int, title: String, can: Int) } diff --git a/SodaLive/Sources/Content/Detail/ContentDetailView.swift b/SodaLive/Sources/Content/Detail/ContentDetailView.swift index b8204e1..0249e40 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailView.swift @@ -230,11 +230,10 @@ struct ContentDetailView: View { AppState.shared .setAppStep( step: .tempCanPayment( + orderType: orderType, + contentId: audioContent.contentId, title: audioContent.title, - can: orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.6)) : audioContent.price, - onSuccess: { - viewModel.order(orderType: orderType) - } + can: orderType == .RENTAL ? Int(ceil(Double(audioContent.price) * 0.6)) : audioContent.price ) ) } else { diff --git a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift index e840677..c00844f 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift @@ -62,7 +62,11 @@ final class ContentDetailViewModel: ObservableObject { let decoded = try jsonDecoder.decode(ApiResponse.self, from: responseData) if let data = decoded.data, decoded.success { - self.audioContent = data + if AppState.shared.purchasedContentId > 0 && AppState.shared.purchasedContentId == data.contentId { + self.order(orderType: AppState.shared.purchasedContentOrderType) + } else { + self.audioContent = data + } } else { if let message = decoded.message { self.errorMessage = message @@ -298,6 +302,9 @@ final class ContentDetailViewModel: ObservableObject { let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) if decoded.success { + AppState.shared.purchasedContentId = 0 + AppState.shared.purchasedContentOrderType = .KEEP + self.orderType = nil self.errorMessage = orderType == .RENTAL ? "대여가 완료되었습니다." : "구매가 완료되었습니다." self.isShowPopup = true diff --git a/SodaLive/Sources/ContentView.swift b/SodaLive/Sources/ContentView.swift index 98ec774..6b6251c 100644 --- a/SodaLive/Sources/ContentView.swift +++ b/SodaLive/Sources/ContentView.swift @@ -187,8 +187,8 @@ struct ContentView: View { case .seriesContentAll(let seriesId, let seriesTitle): SeriesContentAllView(seriesId: seriesId, seriesTitle: seriesTitle) - case .tempCanPayment(let title, let can, let onSuccess): - CanPaymentTempView(title: title, can: can, onSuccess: onSuccess) + case .tempCanPayment(let orderType, let contentId, let title, let can): + CanPaymentTempView(orderType: orderType, contentId: contentId, title: title, can: can) default: diff --git a/SodaLive/Sources/MyPage/Can/Payment/Temp/CanPaymentTempView.swift b/SodaLive/Sources/MyPage/Can/Payment/Temp/CanPaymentTempView.swift index b27f7fa..6144c98 100644 --- a/SodaLive/Sources/MyPage/Can/Payment/Temp/CanPaymentTempView.swift +++ b/SodaLive/Sources/MyPage/Can/Payment/Temp/CanPaymentTempView.swift @@ -13,14 +13,16 @@ struct CanPaymentTempView: View { @StateObject var viewModel = CanPaymentTempViewModel() + let orderType: OrderType + let contentId: Int let title: String let can: Int - let onSuccess: () -> Void - init(title: String, can: Int, onSuccess: @escaping () -> Void) { + init(orderType: OrderType, contentId: Int, title: String, can: Int) { + self.orderType = orderType + self.contentId = contentId self.title = title self.can = can - self.onSuccess = onSuccess } var body: some View { @@ -48,9 +50,11 @@ struct CanPaymentTempView: View { let can = UserDefaults.int(forKey: .can) UserDefaults.set(can + self.can, forKey: .can) - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + AppState.shared.purchasedContentId = contentId + AppState.shared.purchasedContentOrderType = orderType + + DispatchQueue.main.async { AppState.shared.back() - onSuccess() } } } @@ -65,7 +69,7 @@ struct CanPaymentTempView: View { ScrollView(.vertical, showsIndicators: false) { VStack(spacing: 0) { - HStack(spacing: 0) { + HStack(spacing: 0) { Text(self.title) .font(.custom(Font.bold.rawValue, size: 15.3)) .foregroundColor(Color(hex: "eeeeee")) @@ -271,5 +275,5 @@ struct CanPaymentTempView: View { } #Preview { - CanPaymentTempView(title: "콘텐츠 제목", can: 1000, onSuccess: {}) + CanPaymentTempView(orderType: .KEEP, contentId: 0, title: "콘텐츠 제목", can: 1000) } diff --git a/SodaLive/Sources/Settings/SettingsView.swift b/SodaLive/Sources/Settings/SettingsView.swift index 53ee18c..746a819 100644 --- a/SodaLive/Sources/Settings/SettingsView.swift +++ b/SodaLive/Sources/Settings/SettingsView.swift @@ -156,11 +156,10 @@ struct SettingsView: View { .padding(.top, 13.3) Text(""" -- 회사명 : 주식회사 비비드넥스트 -- 대표자 : 한지영 -- 주소 : 서울 강남구 테헤란로 410, 11층 A08호(대치동, 금강타워) -- 사업자등록번호 : 508-86-01545 -- 통신판매업신고 : 제2022-서울강남-00559호 +- 회사명 : 주식회사 소다라이브 +- 대표자 : 이재형 +- 주소 : 경기도 성남시 분당구 황새울로335번길 10, 5층 563A호 (서현동, 멜로즈 프라자) +- 사업자등록번호 : 870-81-03220 - 고객센터 : 02.2055.1477 """) .font(.custom(Font.medium.rawValue, size: 11))