Skip to content

Commit 211e34e

Browse files
committed
fix: conversion
1 parent 14021ef commit 211e34e

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

app/src/main/java/to/bitkit/ui/components/NumberPadTextField.kt

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package to.bitkit.ui.components
22

3+
import android.util.Log
34
import androidx.compose.foundation.clickable
45
import androidx.compose.foundation.layout.Column
56
import androidx.compose.foundation.layout.Row
@@ -36,21 +37,10 @@ fun NumberPadTextField(
3637
val (rates, _, _, _, displayUnit, primaryDisplay) = LocalCurrencies.current
3738
val currency = currencyViewModel ?: return
3839

39-
val satoshis by remember {
40-
derivedStateOf {
41-
val result = if (primaryDisplay == PrimaryDisplay.FIAT) {
42-
currency.convertFiatToSats(fiatAmount = input.toDoubleOrNull() ?: 0.0 ).toString()
43-
} else {
44-
input
45-
}
46-
result
47-
}
48-
}
49-
50-
val convertedAmount by remember {
51-
derivedStateOf {
52-
if (rates.isNotEmpty()) currency.convert(sats = satoshis.toLongOrNull() ?: 0L) else null
53-
}
40+
val satoshis = if (primaryDisplay == PrimaryDisplay.FIAT) {
41+
currency.convertFiatToSats(fiatAmount = input.toDoubleOrNull() ?: 0.0 ).toString()
42+
} else {
43+
input
5444
}
5545

5646
var placeholder: String by remember { mutableStateOf("0") }
@@ -101,7 +91,7 @@ fun NumberPadTextField(
10191
unit = primaryDisplay,
10292
placeholder = placeholder,
10393
showPlaceholder = true,
104-
satoshis = satoshis.toIntOrNull() ?: 0,
94+
satoshis = satoshis.toLongOrNull() ?: 0,
10595
)
10696
}
10797

@@ -112,7 +102,7 @@ fun MoneyAmount(
112102
unit: PrimaryDisplay,
113103
placeholder: String,
114104
showPlaceholder: Boolean,
115-
satoshis: Int,
105+
satoshis: Long,
116106
onPress: () -> Unit = {},
117107
style: TextStyle = TextStyle.Default,
118108
) {
@@ -123,7 +113,7 @@ fun MoneyAmount(
123113
horizontalAlignment = Alignment.Start
124114
) {
125115

126-
MoneySSB(sats = satoshis.toLong(), reversed = true)
116+
MoneySSB(sats = satoshis, reversed = true)
127117

128118
Row(
129119
verticalAlignment = Alignment.CenterVertically

0 commit comments

Comments
 (0)