From e3f9c78b95f72829e31eb56fa37d8d17bc4a4379 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 3 Oct 2024 21:33:58 +0200 Subject: [PATCH] Added informationForUser, but not exposing it to user as it may causes overflow exception of used QR code library --- .../banking/ui/screens/CreateEpcQrCodeScreen.kt | 15 +++++++++++++-- .../banking/ui/service/EpcQrCodeService.kt | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/CreateEpcQrCodeScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/CreateEpcQrCodeScreen.kt index e16b8c9..5405605 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/CreateEpcQrCodeScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/CreateEpcQrCodeScreen.kt @@ -54,11 +54,13 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) { var reference by remember { mutableStateOf("") } + var informationForUser by remember { mutableStateOf("") } - val epcQrCodeBytes by remember(receiverName, iban, bic, amount, reference) { + + 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() }) + epcQrCodeService.generateEpcQrCode(receiverName, iban, bic.takeUnless { it.isBlank() }, amount.takeUnless { it.isBlank() }, reference.takeUnless { it.isBlank() }, informationForUser.takeUnless { it.isBlank() }) } else { null } @@ -152,6 +154,15 @@ fun CreateEpcQrCodeScreen(onClosed: () -> Unit) { modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp), keyboardOptions = KeyboardOptions.ImeNext ) + + // not exposing it to user as it's a) not displayed by most apps and b) may causes overflow of used QR code library +// OutlinedTextField( +// label = { Text("Information für den Nutzer (optional)") }, +// value = informationForUser, +// onValueChange = { informationForUser = it }, +// modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp), +// keyboardOptions = KeyboardOptions.ImeNext +// ) } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/EpcQrCodeService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/EpcQrCodeService.kt index d3fa4ae..467e20a 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/EpcQrCodeService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/EpcQrCodeService.kt @@ -6,10 +6,10 @@ import net.codinux.banking.epcqrcode.EpcQrCodeGenerator class EpcQrCodeService { - fun generateEpcQrCode(receiverName: String, iban: String, bic: String?, amount: String?, reference: String?, heightAndWidth: Int = EpcQrCode.DefaultHeightAndWidth): ByteArray { + fun generateEpcQrCode(receiverName: String, iban: String, bic: String?, amount: String?, reference: String?, informationForUser: String? = null, heightAndWidth: Int = EpcQrCode.DefaultHeightAndWidth): ByteArray { val generator = EpcQrCodeGenerator() - return generator.generateEpcQrCode(EpcQrCodeConfig(receiverName, iban, bic, amount, reference, qrCodeHeightAndWidth = heightAndWidth)).bytes + return generator.generateEpcQrCode(EpcQrCodeConfig(receiverName, iban, bic, amount, reference, informationForUser, qrCodeHeightAndWidth = heightAndWidth)).bytes } } \ No newline at end of file