Skip to content

Commit b37ef78

Browse files
authored
Merge pull request #71 from synonymdev/feat/send-amount-implement-keyboard
Implement the keyboard in the Send Amount Screen
2 parents 262f94e + f46c6fb commit b37ef78

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.ui.text.input.KeyboardType
2424
import androidx.compose.ui.unit.dp
2525
import to.bitkit.R
2626
import to.bitkit.ui.LocalBalances
27+
import to.bitkit.ui.components.Keyboard
2728
import to.bitkit.ui.components.OutlinedColorButton
2829
import to.bitkit.ui.components.PrimaryButton
2930
import to.bitkit.ui.components.Text13Up
@@ -56,14 +57,14 @@ fun SendAmountScreen(
5657
val focusRequester = remember { FocusRequester() }
5758
LaunchedEffect(Unit) { focusRequester.requestFocus() }
5859

59-
TextField(
60+
TextField( //TODO UPDATE IN OTHER PR
6061
placeholder = { Text(stringResource(R.string.amount_placeholder)) },
62+
readOnly = true,
6163
value = uiState.amountInput,
62-
onValueChange = { onEvent(SendEvent.AmountChange(it)) },
64+
onValueChange = { },
6365
colors = AppTextFieldDefaults.noIndicatorColors,
6466
shape = MaterialTheme.shapes.small,
6567
singleLine = true,
66-
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
6768
modifier = Modifier
6869
.fillMaxWidth()
6970
.focusRequester(focusRequester)
@@ -104,15 +105,25 @@ fun SendAmountScreen(
104105
)
105106
}
106107
}
107-
HorizontalDivider()
108108

109109
Spacer(modifier = Modifier.weight(1f))
110110

111+
HorizontalDivider(modifier = Modifier.padding(vertical = 32.dp))
112+
113+
Keyboard(
114+
onClick = { number -> onEvent(SendEvent.AmountChange(number)) },
115+
isDecimal = false, //TODO UPDATE IN OTHER PR
116+
modifier = Modifier.fillMaxWidth(),
117+
)
118+
119+
Spacer(modifier = Modifier.height(41.dp))
120+
111121
PrimaryButton(
112122
text = stringResource(R.string.continue_button),
113123
enabled = uiState.isAmountInputValid,
114124
onClick = { onEvent(SendEvent.AmountContinue(uiState.amountInput)) },
115125
)
126+
116127
Spacer(modifier = Modifier.height(16.dp))
117128
}
118129
}

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,12 @@ class AppViewModel @Inject constructor(
271271
}
272272

273273
private fun onAmountChange(value: String) {
274-
val isAmountValid = validateAmount(value)
275-
_sendUiState.update {
276-
it.copy(
277-
amountInput = value,
278-
isAmountInputValid = isAmountValid,
279-
)
274+
val newInput = if (_sendUiState.value.amountInput == "0") value else _sendUiState.value.amountInput + value
275+
val isAmountValid = validateAmount(newInput)
276+
if (isAmountValid) {
277+
_sendUiState.update { it.copy( amountInput = newInput,) }
280278
}
279+
_sendUiState.update { it.copy(isAmountInputValid = isAmountValid,) }
281280
}
282281

283282
private fun onPaymentMethodSwitch() {

0 commit comments

Comments
 (0)