From 1c03f476d8893f5a5cadf8599aca6def395355b6 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 20 May 2025 18:57:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B5=AC=EB=A7=A4=20=ED=99=95=EC=9D=B8?= =?UTF-8?q?=20Dialog=20-=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9D=B4=20=EA=B0=80=EB=8A=A5=ED=95=9C=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=EB=A5=BC=20=EA=B0=99?= =?UTF-8?q?=EC=9D=B4=20=ED=91=9C=EC=8B=9C=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Detail/ContentDetailView.swift | 1 + .../ContentOrderConfirmDialogView.swift | 49 ++++++++++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/SodaLive/Sources/Content/Detail/ContentDetailView.swift b/SodaLive/Sources/Content/Detail/ContentDetailView.swift index fc0066a..d9cf9c9 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailView.swift @@ -252,6 +252,7 @@ struct ContentDetailView: View { themeStr: audioContent.themeStr, coverImageUrl: audioContent.coverImageUrl, creatorNickname: audioContent.creator.nickname, + isAvailableUsePoint: audioContent.isAvailableUsePoint, creatorProfileImageUrl: audioContent.creator.profileImageUrl, orderType: orderType, onClickConfirm: { diff --git a/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift b/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift index 33805af..242415d 100644 --- a/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift +++ b/SodaLive/Sources/Content/Detail/ContentOrderConfirmDialogView.swift @@ -18,11 +18,15 @@ struct ContentOrderConfirmDialogView: View { let themeStr: String let coverImageUrl: String let creatorNickname: String + let isAvailableUsePoint: Bool let creatorProfileImageUrl: String let orderType: OrderType let onClickConfirm: () -> Void + @State private var usablePoint = 0 + @State private var remainingCan = 0 + var body: some View { ZStack { Color @@ -104,7 +108,7 @@ struct ContentOrderConfirmDialogView: View { .padding(.top, 13.3) if UserDefaults.int(forKey: .userId) != 17958 { - Text("아래 캔이 차감됩니다.") + Text("아래 금액이 차감됩니다.") .font(.custom(Font.medium.rawValue, size: 13.3)) .foregroundColor(Color.grayee) .fixedSize(horizontal: false, vertical: true) @@ -112,17 +116,39 @@ struct ContentOrderConfirmDialogView: View { .padding(.top, 13.3) } - HStack(spacing: 2.7) { + HStack(spacing: 10) { Spacer() if UserDefaults.int(forKey: .userId) != 17958 { - Image("ic_can") - .resizable() - .frame(width: 16.7, height: 16.7) + if usablePoint > 0 { + HStack(spacing: 2.7) { + Image("ic_point") + .resizable() + .frame(width: 16.7, height: 16.7) + + Text("\(usablePoint)") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) + } + } - Text("\(price)") - .font(.custom(Font.bold.rawValue, size: 13.3)) - .foregroundColor(Color.grayee) + if usablePoint > 0 && remainingCan > 0 { + Text("+") + .font(.custom(Font.medium.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) + } + + if remainingCan > 0 { + HStack(spacing: 10) { + Image("ic_can") + .resizable() + .frame(width: 16.7, height: 16.7) + + Text("\(remainingCan)") + .font(.custom(Font.bold.rawValue, size: 13.3)) + .foregroundColor(Color.grayee) + } + } } else { Text("\(price * 110)원") .font(.custom(Font.bold.rawValue, size: 13.3)) @@ -177,5 +203,12 @@ struct ContentOrderConfirmDialogView: View { .cornerRadius(10) .padding(.horizontal, 20) } + .onAppear { + let maxUsablePoint = orderType == OrderType.RENTAL && isAvailableUsePoint ? price * 10 : 0 + let totalAvailablePoint = orderType == OrderType.RENTAL && isAvailableUsePoint ? UserDefaults.int(forKey: .point) : 0 + + self.usablePoint = (min(totalAvailablePoint, maxUsablePoint) / 10) * 10 + self.remainingCan = ((price * 10) - usablePoint) / 10 + } } }