feat: 구매 확인 Dialog
- 포인트 사용이 가능한 경우 포인트를 같이 표시하도록 수정
This commit is contained in:
@@ -252,6 +252,7 @@ struct ContentDetailView: View {
|
|||||||
themeStr: audioContent.themeStr,
|
themeStr: audioContent.themeStr,
|
||||||
coverImageUrl: audioContent.coverImageUrl,
|
coverImageUrl: audioContent.coverImageUrl,
|
||||||
creatorNickname: audioContent.creator.nickname,
|
creatorNickname: audioContent.creator.nickname,
|
||||||
|
isAvailableUsePoint: audioContent.isAvailableUsePoint,
|
||||||
creatorProfileImageUrl: audioContent.creator.profileImageUrl,
|
creatorProfileImageUrl: audioContent.creator.profileImageUrl,
|
||||||
orderType: orderType,
|
orderType: orderType,
|
||||||
onClickConfirm: {
|
onClickConfirm: {
|
||||||
|
|||||||
@@ -18,11 +18,15 @@ struct ContentOrderConfirmDialogView: View {
|
|||||||
let themeStr: String
|
let themeStr: String
|
||||||
let coverImageUrl: String
|
let coverImageUrl: String
|
||||||
let creatorNickname: String
|
let creatorNickname: String
|
||||||
|
let isAvailableUsePoint: Bool
|
||||||
let creatorProfileImageUrl: String
|
let creatorProfileImageUrl: String
|
||||||
|
|
||||||
let orderType: OrderType
|
let orderType: OrderType
|
||||||
let onClickConfirm: () -> Void
|
let onClickConfirm: () -> Void
|
||||||
|
|
||||||
|
@State private var usablePoint = 0
|
||||||
|
@State private var remainingCan = 0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color
|
Color
|
||||||
@@ -104,7 +108,7 @@ struct ContentOrderConfirmDialogView: View {
|
|||||||
.padding(.top, 13.3)
|
.padding(.top, 13.3)
|
||||||
|
|
||||||
if UserDefaults.int(forKey: .userId) != 17958 {
|
if UserDefaults.int(forKey: .userId) != 17958 {
|
||||||
Text("아래 캔이 차감됩니다.")
|
Text("아래 금액이 차감됩니다.")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color.grayee)
|
.foregroundColor(Color.grayee)
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
@@ -112,17 +116,39 @@ struct ContentOrderConfirmDialogView: View {
|
|||||||
.padding(.top, 13.3)
|
.padding(.top, 13.3)
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack(spacing: 2.7) {
|
HStack(spacing: 10) {
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
if UserDefaults.int(forKey: .userId) != 17958 {
|
if UserDefaults.int(forKey: .userId) != 17958 {
|
||||||
Image("ic_can")
|
if usablePoint > 0 {
|
||||||
.resizable()
|
HStack(spacing: 2.7) {
|
||||||
.frame(width: 16.7, height: 16.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)")
|
if usablePoint > 0 && remainingCan > 0 {
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
Text("+")
|
||||||
.foregroundColor(Color.grayee)
|
.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 {
|
} else {
|
||||||
Text("\(price * 110)원")
|
Text("\(price * 110)원")
|
||||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
@@ -177,5 +203,12 @@ struct ContentOrderConfirmDialogView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.padding(.horizontal, 20)
|
.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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user