Implemented selecting account for which EPC QR code should get generated
This commit is contained in:
parent
3d474f38ae
commit
1520d19625
|
@ -9,13 +9,18 @@ import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import net.codinux.banking.persistence.entities.BankAccountEntity
|
||||||
|
import net.codinux.banking.ui.composables.BankIcon
|
||||||
import net.codinux.banking.ui.composables.tan.ImageSizeControls
|
import net.codinux.banking.ui.composables.tan.ImageSizeControls
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.extensions.ImeNext
|
import net.codinux.banking.ui.extensions.ImeNext
|
||||||
import net.codinux.banking.ui.forms.OutlinedTextField
|
import net.codinux.banking.ui.forms.OutlinedTextField
|
||||||
|
import net.codinux.banking.ui.forms.Select
|
||||||
import net.codinux.banking.ui.service.createImageBitmap
|
import net.codinux.banking.ui.service.createImageBitmap
|
||||||
|
|
||||||
private val epcQrCodeService = DI.epcQrCodeService
|
private val epcQrCodeService = DI.epcQrCodeService
|
||||||
|
@ -23,6 +28,22 @@ private val epcQrCodeService = DI.epcQrCodeService
|
||||||
@Composable
|
@Composable
|
||||||
fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
|
fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
|
||||||
|
|
||||||
|
val banks = DI.uiState.banks.collectAsState().value
|
||||||
|
|
||||||
|
val accountsWithIban: List<BankAccountEntity?> = buildList {
|
||||||
|
add(null)
|
||||||
|
addAll(DI.uiState.accounts.collectAsState().value.filter { it.iban != null })
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedAccount by remember { mutableStateOf<BankAccountEntity?>(null) }
|
||||||
|
|
||||||
|
val bankOfSelectedAccount by remember(selectedAccount) {
|
||||||
|
derivedStateOf { banks.firstOrNull { it.id == selectedAccount?.bankId } }
|
||||||
|
}
|
||||||
|
|
||||||
|
val amountFocus = remember { FocusRequester() }
|
||||||
|
|
||||||
|
|
||||||
var receiverName by remember { mutableStateOf("") }
|
var receiverName by remember { mutableStateOf("") }
|
||||||
|
|
||||||
var iban by remember { mutableStateOf("") }
|
var iban by remember { mutableStateOf("") }
|
||||||
|
@ -65,6 +86,33 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Select(
|
||||||
|
"Für Konto",
|
||||||
|
accountsWithIban,
|
||||||
|
selectedAccount,
|
||||||
|
{ account ->
|
||||||
|
selectedAccount = account
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
iban = account.iban ?: ""
|
||||||
|
bic = banks.firstOrNull { it.id == selectedAccount?.bankId }?.bic ?: ""
|
||||||
|
receiverName = account.accountHolderName
|
||||||
|
|
||||||
|
amountFocus.requestFocus()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ account -> account?.displayName ?: "" },
|
||||||
|
leadingIcon = bankOfSelectedAccount?.let { { BankIcon(bankOfSelectedAccount) } },
|
||||||
|
dropDownItemContent = { account ->
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
BankIcon(banks.firstOrNull { it.id == account?.bankId }, Modifier.padding(end = 6.dp))
|
||||||
|
|
||||||
|
Text(account?.displayName ?: "")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier.fillMaxWidth().padding(top = 16.dp, bottom = 8.dp)
|
||||||
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
label = { Text("Empfänger*in") },
|
label = { Text("Empfänger*in") },
|
||||||
value = receiverName,
|
value = receiverName,
|
||||||
|
@ -93,7 +141,7 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
|
||||||
label = { Text("Betrag (optional)") },
|
label = { Text("Betrag (optional)") },
|
||||||
value = amount,
|
value = amount,
|
||||||
onValueChange = { amount = it },
|
onValueChange = { amount = it },
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
|
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp).focusRequester(amountFocus),
|
||||||
keyboardOptions = KeyboardOptions.ImeNext
|
keyboardOptions = KeyboardOptions.ImeNext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue