fix: show fiat conversion on paymentsent
This commit is contained in:
@@ -25,6 +25,8 @@ import com.bitcointxoko.gudariwallet.ui.send.LnurlInvoiceConfirmCard
|
|||||||
import com.bitcointxoko.gudariwallet.ui.send.LnurlPayForm
|
import com.bitcointxoko.gudariwallet.ui.send.LnurlPayForm
|
||||||
import com.bitcointxoko.gudariwallet.util.SendInputDetector
|
import com.bitcointxoko.gudariwallet.util.SendInputDetector
|
||||||
import com.bitcointxoko.gudariwallet.util.feePpm
|
import com.bitcointxoko.gudariwallet.util.feePpm
|
||||||
|
import com.bitcointxoko.gudariwallet.util.formatFiat
|
||||||
|
import com.bitcointxoko.gudariwallet.util.satsToFiat
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -35,11 +37,11 @@ fun SendScreen(vm: WalletViewModel) {
|
|||||||
val activity = context as FragmentActivity
|
val activity = context as FragmentActivity
|
||||||
val clipboard = LocalClipboard.current
|
val clipboard = LocalClipboard.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
val balanceState by vm.balanceState.collectAsStateWithLifecycle()
|
||||||
// Read rate directly from VM cache — same source HomeTab uses.
|
val fiatRate = (balanceState as? BalanceState.Success)?.let { s ->
|
||||||
// Both are null when no currency is selected; fiat display is suppressed.
|
s.fiatAmount?.let { if (s.sats > 0) s.sats.toDouble() / it else null }
|
||||||
val fiatRate = vm.fiatRate // Double?
|
}
|
||||||
val fiatCurrency = vm.fiatCurrency // String?
|
val fiatCurrency = (balanceState as? BalanceState.Success)?.fiatCurrency
|
||||||
|
|
||||||
DisposableEffect(Unit) { onDispose { vm.resetSendState() } }
|
DisposableEffect(Unit) { onDispose { vm.resetSendState() } }
|
||||||
|
|
||||||
@@ -169,7 +171,16 @@ fun SendScreen(vm: WalletViewModel) {
|
|||||||
text = "${state.amountSats} sats",
|
text = "${state.amountSats} sats",
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
val fiatAmount = if (fiatRate != null && fiatCurrency != null) {
|
||||||
|
satsToFiat(state.amountSats, fiatRate)
|
||||||
|
} else null
|
||||||
|
if (fiatAmount != null && fiatCurrency != null) {
|
||||||
|
Text(
|
||||||
|
text = "≈ ${formatFiat(fiatAmount, fiatCurrency)}",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
val feeText = when {
|
val feeText = when {
|
||||||
state.feeSats == null || state.feeSats == 0L -> "No fees"
|
state.feeSats == null || state.feeSats == 0L -> "No fees"
|
||||||
|
|||||||
Reference in New Issue
Block a user