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 | 41 |
1 files changed, 22 insertions, 19 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 1ff3423..d356051 100644 --- a/wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/deposit/MakeBitcoinDepositComposable.kt @@ -22,10 +22,11 @@ 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.material.Button -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -39,7 +40,6 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -71,6 +71,7 @@ fun MakeBitcoinDepositComposable( .padding(16.dp) .focusRequester(focusRequester), value = address, + singleLine = true, enabled = !state.showFees, onValueChange = { input -> address = input @@ -80,7 +81,7 @@ fun MakeBitcoinDepositComposable( Text( stringResource(R.string.send_deposit_bitcoin_address), color = if (address.isBlank()) { - colorResource(R.color.red) + MaterialTheme.colorScheme.error } else Color.Unspecified, ) } @@ -90,7 +91,7 @@ fun MakeBitcoinDepositComposable( } val amountTitle = if (state.effectiveDepositAmount == null) { R.string.amount_chosen - } else R.string.send_deposit_amount_effective + } else R.string.amount_effective TransactionAmountComposable( label = stringResource(id = amountTitle), amount = state.effectiveDepositAmount ?: amount, @@ -103,14 +104,16 @@ fun MakeBitcoinDepositComposable( ) { val totalAmount = state.totalDepositCost ?: amount val effectiveAmount = state.effectiveDepositAmount ?: Amount.zero(amount.currency) - val fee = totalAmount - effectiveAmount + if (totalAmount > effectiveAmount) { + val fee = totalAmount - effectiveAmount + TransactionAmountComposable( + label = stringResource(id = R.string.amount_fee), + amount = fee, + amountType = AmountType.Negative, + ) + } TransactionAmountComposable( - label = stringResource(id = R.string.withdraw_fees), - amount = fee, - amountType = AmountType.Negative, - ) - TransactionAmountComposable( - label = stringResource(id = R.string.send_amount), + label = stringResource(id = R.string.amount_send), amount = totalAmount, amountType = AmountType.Positive, ) @@ -120,8 +123,8 @@ fun MakeBitcoinDepositComposable( Text( modifier = Modifier.padding(16.dp), fontSize = 18.sp, - color = colorResource(R.color.red), - text = (state as? DepositState.Error)?.msg ?: "", + color = MaterialTheme.colorScheme.error, + text = (state as? DepositState.Error)?.error?.userFacingMsg ?: "", ) } val focusManager = LocalFocusManager.current @@ -147,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")) { _, _ -> } } } |