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 + } } }