Show a flag emoji next to each currency code
Derives a country flag from the ISO 4217 code's country prefix, with an explicit map of country codes for currencies shared by multiple countries (XAF, XCD, XCG, XOF, XPF) showing every issuing country's flag, and the EU flag as a special case for EUR. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QpjMKWGoiT5aJBzhxvXkwp
This commit is contained in:
@@ -124,7 +124,7 @@ struct ContentView: View {
|
||||
|
||||
ForEach(Array(state.fiatRows.enumerated()), id: \.element.code) { index, row in
|
||||
amountRow(
|
||||
label: row.code,
|
||||
label: currencyFieldLabel(for: row.code),
|
||||
value: row.amount,
|
||||
keyboardType: .decimalPad,
|
||||
sanitize: sanitizeDecimalInput,
|
||||
@@ -311,6 +311,13 @@ private struct NumericField: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func currencyFieldLabel(for code: String) -> String {
|
||||
if let flag = CurrencyFlagKt.currencyFlagEmoji(code: code) {
|
||||
return "\(flag) \(code)"
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
/// Unlike the shared Kotlin `sanitizeDecimalInput` (which never sees grouping separators, since
|
||||
/// Compose's VisualTransformation never feeds its grouped display back into the real value),
|
||||
/// `NumericField`'s single `text` buffer *is* the grouped display, re-fed through this on every
|
||||
|
||||
@@ -81,16 +81,21 @@ struct CurrencyPickerSheet: View {
|
||||
}
|
||||
|
||||
private func currencyLabel(for info: CurrencyInfo) -> String {
|
||||
let text: String
|
||||
if info.code == localeCurrencyCode {
|
||||
return IosLocalizationKt.localizedFormattedString(
|
||||
text = IosLocalizationKt.localizedFormattedString(
|
||||
resource: MR.strings.shared.currency_option_label_local,
|
||||
args: [info.code, info.displayName]
|
||||
)
|
||||
} else {
|
||||
return IosLocalizationKt.localizedFormattedString(
|
||||
text = IosLocalizationKt.localizedFormattedString(
|
||||
resource: MR.strings.shared.currency_option_label,
|
||||
args: [info.code, info.displayName]
|
||||
)
|
||||
}
|
||||
if let flag = CurrencyFlagKt.currencyFlagEmoji(code: info.code) {
|
||||
return "\(flag) \(text)"
|
||||
}
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user