@@ -22,6 +22,8 @@ import androidx.compose.ui.tooling.preview.Preview
2222import androidx.compose.ui.unit.dp
2323import okhttp3.internal.toLongOrDefault
2424import to.bitkit.R
25+ import to.bitkit.ext.removeSpaces
26+ import to.bitkit.models.BitcoinDisplayUnit
2527import to.bitkit.models.NodeLifecycleState
2628import to.bitkit.models.PrimaryDisplay
2729import to.bitkit.ui.LocalBalances
@@ -72,6 +74,20 @@ fun SendAmountScreen(
7274 }
7375 }
7476
77+ LaunchedEffect (Unit ) {
78+ val sats: String = when (currencyUiState.primaryDisplay) {
79+ PrimaryDisplay .BITCOIN -> {
80+ if (currencyUiState.displayUnit == BitcoinDisplayUnit .MODERN ) input else (input.toLongOrDefault(0L ) * 100_000_000 ).toString()
81+ }
82+
83+ PrimaryDisplay .FIAT -> {
84+ val convertedAmount = currencyVM.convertFiatToSats(input.toDoubleOrNull() ? : 0.0 ) ? : 0L
85+ convertedAmount.toString()
86+ }
87+ }
88+ onEvent(SendEvent .AmountChange (value = sats))
89+ }
90+
7591 Column (
7692 modifier = Modifier
7793 .fillMaxSize()
@@ -142,11 +158,9 @@ fun SendAmountScreen(
142158 Keyboard (
143159 onClick = { number ->
144160 if (input == " 0" ) input = number else input+ = number
145- onEvent(SendEvent .AmountChange (number))
146161 },
147162 onClickBackspace = {
148163 input = if (input.length > 1 ) input.dropLast(1 ) else " 0"
149- onEvent(SendEvent .BackSpaceClick )
150164 },
151165 isDecimal = currencyUiState.primaryDisplay == PrimaryDisplay .FIAT ,
152166 modifier = Modifier .fillMaxWidth(),
0 commit comments