From 293c822c86ad0a85cb8befc4642b9d1a77f2e056 Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Thu, 10 Sep 2026 12:24:13 +0300 Subject: [PATCH] Reject decimal input in the manual "currency to Sats" field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was using the decimal sanitizer/keyboard, same as the rate field next to it — but Sats are indivisible, so this one should behave like the existing Sats amount field: integers only, numeric keypad. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy --- iosApp/iosApp/ContentView.swift | 4 ++-- .../commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceScreen.kt | 2 +- .../commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/iosApp/iosApp/ContentView.swift b/iosApp/iosApp/ContentView.swift index 7c7f882..f44e724 100644 --- a/iosApp/iosApp/ContentView.swift +++ b/iosApp/iosApp/ContentView.swift @@ -115,8 +115,8 @@ struct ContentView: View { NumericField( placeholder: "", value: state.manualSatsPerCurrencyInput, - keyboardType: .decimalPad, - sanitize: sanitizeDecimalInput, + keyboardType: .numberPad, + sanitize: sanitizeIntegerInput, onChange: { viewModel.onManualSatsPerCurrencyChanged($0) }, alignment: .trailing ) diff --git a/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceScreen.kt b/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceScreen.kt index 5f7c875..036ae9e 100644 --- a/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceScreen.kt +++ b/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceScreen.kt @@ -214,7 +214,7 @@ fun PriceScreen( value = state.manualSatsPerCurrencyInput, onValueChange = viewModel::onManualSatsPerCurrencyChanged, label = { Text(stringResource(MR.strings.currency_to_sats, state.defaultCurrencyCode)) }, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), singleLine = true, visualTransformation = DigitGroupingTransformation, modifier = Modifier.fillMaxWidth(), diff --git a/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt b/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt index caa605d..039a1ba 100644 --- a/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt +++ b/shared/src/commonMain/kotlin/xyz/tyiu/satsprice/ui/PriceViewModel.kt @@ -294,7 +294,8 @@ class PriceViewModel( } fun onManualSatsPerCurrencyChanged(value: String) { - val sanitized = sanitizeDecimalInput(value) + // Sats are indivisible — unlike the rate field, this one takes whole numbers only. + val sanitized = sanitizeIntegerInput(value) val parsedSats = sanitized.toBigDecimalOrNull() val rate = parsedSats?.let { sats -> CurrencyConverter.satsPerCurrencyUnit(sats) } manualSource.rate = rate