Fixed that entering text for amount or reference didn't reduce the autocomplete suggestions
This commit is contained in:
parent
ee3faa7de1
commit
5ac65308bb
|
@ -210,7 +210,7 @@ fun TransferMoneyDialog(
|
|||
paymentReference = it.reference
|
||||
}
|
||||
},
|
||||
fetchSuggestions = { recipientFinder.findPaymentDataForIban(recipientAccountIdentifier) }
|
||||
fetchSuggestions = { query -> recipientFinder.findAmountPaymentDataForIban(recipientAccountIdentifier, query) }
|
||||
) { paymentDataSuggestion ->
|
||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(formatUtil.formatAmount(paymentDataSuggestion.amount, paymentDataSuggestion.currency), Modifier.widthIn(min = 60.dp), textAlign = TextAlign.End)
|
||||
|
@ -230,7 +230,7 @@ fun TransferMoneyDialog(
|
|||
getItemTitle = { suggestion -> suggestion.reference },
|
||||
onEnteredTextChanged = { paymentReference = it },
|
||||
onSelectedItemChanged = { paymentReference = it?.reference ?: "" },
|
||||
fetchSuggestions = { recipientFinder.findPaymentDataForIban(recipientAccountIdentifier) }
|
||||
fetchSuggestions = { query -> recipientFinder.findReferencePaymentDataForIban(recipientAccountIdentifier, query) }
|
||||
) { paymentDataSuggestion ->
|
||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(formatUtil.formatAmount(paymentDataSuggestion.amount, paymentDataSuggestion.currency), Modifier.widthIn(min = 60.dp), textAlign = TextAlign.End)
|
||||
|
|
|
@ -30,6 +30,15 @@ class RecipientFinder(private val bankFinder: BankFinder) {
|
|||
}
|
||||
}
|
||||
|
||||
fun findAmountPaymentDataForIban(iban: String, query: String): Collection<PaymentDataSuggestion> =
|
||||
transactionsByIban[iban].orEmpty()
|
||||
.filter { it.amount.toString().contains(query, true) }
|
||||
|
||||
fun findReferencePaymentDataForIban(iban: String, query: String): Collection<PaymentDataSuggestion> =
|
||||
transactionsByIban[iban].orEmpty()
|
||||
.filter { it.reference.contains(query, true) }
|
||||
|
||||
|
||||
suspend fun updateData(transactions: List<AccountTransaction>) {
|
||||
availableRecipients = transactions.mapNotNull {
|
||||
// TODO: also regard userSetOtherPartyName?
|
||||
|
@ -51,7 +60,4 @@ class RecipientFinder(private val bankFinder: BankFinder) {
|
|||
}.toSet().sortedByDescending { it.valueDate } }
|
||||
}
|
||||
|
||||
fun findPaymentDataForIban(iban: String): Collection<PaymentDataSuggestion> =
|
||||
transactionsByIban[iban] ?: emptySet()
|
||||
|
||||
}
|
Loading…
Reference in New Issue