Skip to content

Commit 048a7dc

Browse files
committed
feat. trigger amount send event
1 parent 2360c73 commit 048a7dc

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import androidx.compose.ui.tooling.preview.Preview
2222
import androidx.compose.ui.unit.dp
2323
import okhttp3.internal.toLongOrDefault
2424
import to.bitkit.R
25+
import to.bitkit.ext.removeSpaces
26+
import to.bitkit.models.BitcoinDisplayUnit
2527
import to.bitkit.models.NodeLifecycleState
2628
import to.bitkit.models.PrimaryDisplay
2729
import 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

Comments
 (0)