Implemented catching and displaying EPC QR Code generation errors
This commit is contained in:
parent
e3f9c78b95
commit
c89220bc0c
|
@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.*
|
|||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -21,7 +22,9 @@ import net.codinux.banking.ui.config.DI
|
|||
import net.codinux.banking.ui.extensions.ImeNext
|
||||
import net.codinux.banking.ui.forms.OutlinedTextField
|
||||
import net.codinux.banking.ui.forms.Select
|
||||
import net.codinux.banking.ui.model.Config.NewLine
|
||||
import net.codinux.banking.ui.service.createImageBitmap
|
||||
import net.codinux.log.Log
|
||||
|
||||
private val epcQrCodeService = DI.epcQrCodeService
|
||||
|
||||
|
@ -57,10 +60,18 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
|
|||
var informationForUser by remember { mutableStateOf("") }
|
||||
|
||||
|
||||
var epcQrCodeGeneratingError by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
val epcQrCodeBytes by remember(receiverName, iban, bic, amount, reference, informationForUser) {
|
||||
derivedStateOf {
|
||||
if (receiverName.isNotBlank() && iban.isNotBlank()) {
|
||||
epcQrCodeService.generateEpcQrCode(receiverName, iban, bic.takeUnless { it.isBlank() }, amount.takeUnless { it.isBlank() }, reference.takeUnless { it.isBlank() }, informationForUser.takeUnless { it.isBlank() })
|
||||
try {
|
||||
epcQrCodeService.generateEpcQrCode(receiverName, iban, bic.takeUnless { it.isBlank() }, amount.takeUnless { it.isBlank() }, reference.takeUnless { it.isBlank() }, informationForUser.takeUnless { it.isBlank() })
|
||||
} catch (e: Throwable) {
|
||||
Log.error(e) { "Could not generate EPC QR Code" }
|
||||
epcQrCodeGeneratingError = e.message
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
@ -74,7 +85,9 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) {
|
|||
|
||||
FullscreenViewBase("EPC QR Code erstellen", "Schließen", onClosed = onClosed) {
|
||||
Column(Modifier.fillMaxWidth().verticalScroll(rememberScrollState())) {
|
||||
if (epcQrCodeBytes == null) {
|
||||
if (epcQrCodeGeneratingError != null) {
|
||||
Text("QR Code konnte nicht erstellt werden:${NewLine}$epcQrCodeGeneratingError", color = MaterialTheme.colors.error, modifier = Modifier.padding(vertical = 8.dp))
|
||||
} else if (epcQrCodeBytes == null) {
|
||||
Text("Mit EPC QR Codes, welche als GiroCode, scan2code, ... vermarktet werden, können Überweisungsdaten ganz einfach von Banking Apps eingelesen werden.")
|
||||
Text("Hier können Sie Ihren eigenen erstellen, so dass jemand Ihre Überweisungsdaten einlesen und Ihnen ganz schnell Geld überweisen kann.")
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue