feat: 구매 확인 Dialog
- 포인트 사용이 가능한 경우 포인트를 같이 표시하도록 수정
This commit is contained in:
		@@ -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
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user