Wasn't aware of ExposedDropdownMenuDefaults.TrailingIcon, using now that one instead of implementing the functionality by myself

This commit is contained in:
dankito 2024-09-05 00:07:44 +02:00
parent d22ff34a37
commit 5a49e48ea8
3 changed files with 4 additions and 14 deletions

View File

@ -88,7 +88,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
Row(Modifier.padding(top = 16.dp)) {
Select(
"TAN Verfahren", "Alle TAN Medien anzeigen",
"TAN Verfahren",
challenge.availableTanMethods.sortedBy { it.identifier },
challenge.selectedTanMethod,
{ Log.info { "User selected TanMethod $it" } }, // TODO: change TanMethod
@ -99,7 +99,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
if (challenge.availableTanMedia.isNotEmpty()) {
Row(Modifier.padding(top = 16.dp)) {
Select(
"TAN Medium", "Alle TAN Medien anzeigen",
"TAN Medium",
challenge.availableTanMedia.sortedBy { it.status }.map { it.displayName },
challenge.selectedTanMedium?.displayName ?: "<Keines ausgewählt>",
{ Log.info { "User selected TanMedium $it" } }, // TODO: change TanMethod

View File

@ -118,7 +118,7 @@ fun TransferMoneyDialog(
) {
if (accountsSupportingTransferringMoney.size > 1) {
Select(
"Konto", "Alle Konten anzeigen",
"Konto",
accountsSupportingTransferringMoney, senderAccount, { senderAccount = it },
{ account -> "${accountsToUserAccount[account]?.displayName} ${account.displayName}" },
{ BankIcon(accountsToUserAccount[senderAccount]) }

View File

@ -2,9 +2,6 @@ package net.codinux.banking.ui.forms
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.filled.ArrowDropUp
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
@ -12,7 +9,6 @@ import androidx.compose.ui.Modifier
@Composable
fun <T> Select(
label: String,
contentDescription: String,
items: Collection<T>,
selectedItem: T,
onSelectedItemChanged: (T) -> Unit,
@ -30,13 +26,7 @@ fun <T> Select(
label = { Text(label) },
readOnly = true,
maxLines = 1,
trailingIcon = {
if (showDropDownMenu) {
Icon(Icons.Filled.ArrowDropUp, contentDescription)
} else {
Icon(Icons.Filled.ArrowDropDown, contentDescription)
}
},
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(showDropDownMenu) },
leadingIcon = leadingIcon
)