Skip to content

Commit 6194551

Browse files
committed
Fix amount field input
1 parent 60e207e commit 6194551

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • Variant-Esplora/app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/screens/wallet

Variant-Esplora/app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/screens/wallet/SendScreen.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.width
2424
import androidx.compose.foundation.lazy.LazyColumn
2525
import androidx.compose.foundation.lazy.itemsIndexed
2626
import androidx.compose.foundation.shape.RoundedCornerShape
27+
import androidx.compose.foundation.text.KeyboardOptions
2728
import androidx.compose.material3.AlertDialog
2829
import androidx.compose.material3.BottomSheetScaffold
2930
import androidx.compose.material3.BottomSheetScaffoldState
@@ -53,6 +54,7 @@ import androidx.compose.ui.graphics.Color
5354
import androidx.compose.ui.platform.LocalContext
5455
import androidx.compose.ui.semantics.Role
5556
import androidx.compose.ui.text.TextStyle
57+
import androidx.compose.ui.text.input.KeyboardType
5658
import androidx.compose.ui.text.style.TextAlign
5759
import androidx.compose.ui.unit.dp
5860
import androidx.compose.ui.unit.sp
@@ -351,9 +353,11 @@ private fun TransactionAmountInput(recipientList: MutableList<Recipient>, transa
351353
.padding(vertical = 8.dp)
352354
.weight(0.5f),
353355
value = amount.value,
354-
onValueChange = {
355-
amount.value = it
356-
recipientList[index].amount = it.toULong()
356+
onValueChange = { newValue ->
357+
if (newValue.all { it.isDigit() }) {
358+
amount.value = newValue
359+
recipientList[index].amount = newValue.toULongOrNull() ?: 0.toULong()
360+
}
357361
},
358362
label = {
359363
when (transactionType) {
@@ -372,6 +376,7 @@ private fun TransactionAmountInput(recipientList: MutableList<Recipient>, transa
372376
}
373377
}
374378
},
379+
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
375380
singleLine = true,
376381
textStyle = TextStyle(color = DevkitWalletColors.white),
377382
colors = OutlinedTextFieldDefaults.colors(

0 commit comments

Comments
 (0)