diff options
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt b/wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt index e022ed3..ec869f9 100644 --- a/wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt @@ -22,9 +22,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Button -import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -51,7 +50,6 @@ import net.taler.wallet.R import net.taler.wallet.transactions.AmountType import net.taler.wallet.transactions.TransactionAmountComposable -@OptIn(ExperimentalMaterial3Api::class) @Composable fun MakeBitcoinDepositComposable( state: DepositState, @@ -73,6 +71,7 @@ fun MakeBitcoinDepositComposable( .padding(16.dp) .focusRequester(focusRequester), value = address, + singleLine = true, enabled = !state.showFees, onValueChange = { input -> address = input @@ -105,12 +104,14 @@ fun MakeBitcoinDepositComposable( ) { val totalAmount = state.totalDepositCost ?: amount val effectiveAmount = state.effectiveDepositAmount ?: Amount.zero(amount.currency) - val fee = totalAmount - effectiveAmount - TransactionAmountComposable( - label = stringResource(id = R.string.withdraw_fees), - amount = fee, - amountType = AmountType.Negative, - ) + if (totalAmount > effectiveAmount) { + val fee = totalAmount - effectiveAmount + TransactionAmountComposable( + label = stringResource(id = R.string.withdraw_fees), + amount = fee, + amountType = AmountType.Negative, + ) + } TransactionAmountComposable( label = stringResource(id = R.string.send_amount), amount = totalAmount, @@ -123,7 +124,7 @@ fun MakeBitcoinDepositComposable( modifier = Modifier.padding(16.dp), fontSize = 18.sp, color = MaterialTheme.colorScheme.error, - text = (state as? DepositState.Error)?.msg ?: "", + text = (state as? DepositState.Error)?.error?.userFacingMsg ?: "", ) } val focusManager = LocalFocusManager.current @@ -149,12 +150,12 @@ fun MakeBitcoinDepositComposable( fun PreviewMakeBitcoinDepositComposable() { Surface { val state = DepositState.FeesChecked( - effectiveDepositAmount = Amount.fromDouble(CURRENCY_BTC, 42.00), - totalDepositCost = Amount.fromDouble(CURRENCY_BTC, 42.23), + effectiveDepositAmount = Amount.fromString(CURRENCY_BTC, "42.00"), + totalDepositCost = Amount.fromString(CURRENCY_BTC, "42.23"), ) MakeBitcoinDepositComposable( state = state, - amount = Amount.fromDouble(CURRENCY_BTC, 42.23)) { _, _ -> + amount = Amount.fromString(CURRENCY_BTC, "42.23")) { _, _ -> } } } |