Skip to content

Commit 4f33cda

Browse files
committed
fix: decimal validation
1 parent 9ea4367 commit 4f33cda

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/src/main/java/to/bitkit/ui/screens/wallets/send/SendAmountScreen.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import to.bitkit.viewmodels.MainUiState
4444
import to.bitkit.viewmodels.SendEvent
4545
import to.bitkit.viewmodels.SendMethod
4646
import to.bitkit.viewmodels.SendUiState
47+
import java.math.BigDecimal
4748

4849
@Composable
4950
fun SendAmountScreen(
@@ -60,11 +61,13 @@ fun SendAmountScreen(
6061
LaunchedEffect(currencyUiState.primaryDisplay) {
6162
input = when(currencyUiState.primaryDisplay) {
6263
PrimaryDisplay.BITCOIN -> {
63-
currencyVM.convertFiatToSats(input.toDoubleOrNull() ?: 0.0).toString()
64+
val amountLong = currencyVM.convertFiatToSats(input.toDoubleOrNull() ?: 0.0) ?: 0
65+
if (amountLong > 0.0) amountLong.toString() else ""
6466
}
6567

6668
PrimaryDisplay.FIAT -> {
67-
currencyVM.convert(input.toLongOrDefault(0L))?.formatted.toString().replace(".00", "")
69+
val convertedAmount = currencyVM.convert(input.toLongOrDefault(0L))
70+
if ((convertedAmount?.value ?: BigDecimal(0)) > BigDecimal(0)) convertedAmount?.formatted.toString() else ""
6871
}
6972
}
7073
}

0 commit comments

Comments
 (0)