Reject decimal input in the manual "currency to Sats" field
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user