feat(can-payment): 다국적 통화 표기 지원 및 결제 금액 표시 개선
- KRW 고정 표기에서 벗어나 PG/해외 결제 등 다양한 통화 표기를 정확히 지원하기 위함
This commit is contained in:
		@@ -44,4 +44,14 @@ extension String {
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        // 출처 - https://ios-development.tistory.com/379
 | 
					        // 출처 - https://ios-development.tistory.com/379
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    func formatCurrency(currencyCode: String, locale: Locale = .current) -> String {
 | 
				
			||||||
 | 
					        let formatter = NumberFormatter()
 | 
				
			||||||
 | 
					        formatter.numberStyle = .currency
 | 
				
			||||||
 | 
					        formatter.locale = locale
 | 
				
			||||||
 | 
					        formatter.currencyCode = currencyCode
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        let dec = NSDecimalNumber(string: self)
 | 
				
			||||||
 | 
					        return formatter.string(from: dec) ?? "\(currencyCode) \(self)"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -124,7 +124,7 @@ struct CanPgItemView: View {
 | 
				
			|||||||
            
 | 
					            
 | 
				
			||||||
            Spacer()
 | 
					            Spacer()
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            Text("\(item.price) 원")
 | 
					            Text(item.priceStr.formatCurrency(currencyCode: item.currency))
 | 
				
			||||||
                .font(.custom(Font.bold.rawValue, size: 15.3))
 | 
					                .font(.custom(Font.bold.rawValue, size: 15.3))
 | 
				
			||||||
                .foregroundColor(Color(hex: "eeeeee"))
 | 
					                .foregroundColor(Color(hex: "eeeeee"))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,4 +13,6 @@ struct GetCanResponse: Decodable, Hashable {
 | 
				
			|||||||
    let can: Int
 | 
					    let can: Int
 | 
				
			||||||
    let rewardCan: Int
 | 
					    let rewardCan: Int
 | 
				
			||||||
    let price: Int
 | 
					    let price: Int
 | 
				
			||||||
 | 
					    let currency: String
 | 
				
			||||||
 | 
					    let priceStr: String
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -117,7 +117,7 @@ struct CanPgPaymentView: View {
 | 
				
			|||||||
                                    
 | 
					                                    
 | 
				
			||||||
                                    Spacer()
 | 
					                                    Spacer()
 | 
				
			||||||
                                    
 | 
					                                    
 | 
				
			||||||
                                    Text("\(canResponse.price) 원")
 | 
					                                    Text(canResponse.priceStr.formatCurrency(currencyCode: canResponse.currency))
 | 
				
			||||||
                                        .font(.custom(Font.bold.rawValue, size: 15.3))
 | 
					                                        .font(.custom(Font.bold.rawValue, size: 15.3))
 | 
				
			||||||
                                        .foregroundColor(Color.grayee)
 | 
					                                        .foregroundColor(Color.grayee)
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
@@ -281,7 +281,7 @@ struct CanPgPaymentView: View {
 | 
				
			|||||||
                                    .foregroundColor(Color.grayee)
 | 
					                                    .foregroundColor(Color.grayee)
 | 
				
			||||||
                                
 | 
					                                
 | 
				
			||||||
                                HStack(spacing: 0) {
 | 
					                                HStack(spacing: 0) {
 | 
				
			||||||
                                    Text("\(canResponse.price) 원")
 | 
					                                    Text(canResponse.priceStr.formatCurrency(currencyCode: canResponse.currency))
 | 
				
			||||||
                                        .font(.custom(Font.bold.rawValue, size: 23.3))
 | 
					                                        .font(.custom(Font.bold.rawValue, size: 23.3))
 | 
				
			||||||
                                        .foregroundColor(Color.grayee)
 | 
					                                        .foregroundColor(Color.grayee)
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
@@ -378,7 +378,7 @@ struct CanPgPaymentView: View {
 | 
				
			|||||||
struct CanPgPaymentView_Previews: PreviewProvider {
 | 
					struct CanPgPaymentView_Previews: PreviewProvider {
 | 
				
			||||||
    static var previews: some View {
 | 
					    static var previews: some View {
 | 
				
			||||||
        CanPgPaymentView(
 | 
					        CanPgPaymentView(
 | 
				
			||||||
            canResponse: GetCanResponse(id: 1, title: "300 캔", can: 300, rewardCan: 0, price: 7500),
 | 
					            canResponse: GetCanResponse(id: 1, title: "300 캔", can: 300, rewardCan: 0, price: 7500, currency: "USD", priceStr: "5.99"),
 | 
				
			||||||
            refresh: {},
 | 
					            refresh: {},
 | 
				
			||||||
            afterCompletionToGoBack: false
 | 
					            afterCompletionToGoBack: false
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user