From 1970eff09aaf7a3dd7e25526ea03f9389a88ee7c Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 26 Sep 2024 06:33:02 +0200 Subject: [PATCH] Cut displayed text on iOS as otherwise view crashes (displays only a white screen then) --- .../codinux/banking/ui/screens/ExportScreen.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ExportScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ExportScreen.kt index b3b75b1..7253054 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ExportScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ExportScreen.kt @@ -15,12 +15,16 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.codinux.banking.persistence.entities.AccountTransactionEntity import net.codinux.banking.ui.IOorDefault +import net.codinux.banking.ui.PlatformType import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.DI import net.codinux.banking.ui.extensions.horizontalScroll import net.codinux.banking.ui.extensions.verticalScroll import net.codinux.banking.ui.service.BankDataImporterAndExporter + +private const val iOSMaxDisplayedDataLength = 20_000 + @Composable fun ExportScreen(onClosed: () -> Unit) { var transactions: Collection @@ -29,6 +33,8 @@ fun ExportScreen(onClosed: () -> Unit) { var exportedDataText by remember { mutableStateOf("") } + var exportedDataTextToDisplay by remember { mutableStateOf("") } + val importerExporter = BankDataImporterAndExporter() val clipboardManager = LocalClipboardManager.current @@ -42,12 +48,15 @@ fun ExportScreen(onClosed: () -> Unit) { withContext(Dispatchers.Main) { exportedDataText = initiallyExportedData + exportedDataTextToDisplay = if (DI.platform.type == PlatformType.iOS && exportedDataText.length > iOSMaxDisplayedDataLength) exportedDataText.substring(0, + iOSMaxDisplayedDataLength) + "\r\n...\r\n(Wir mussten die Anzeige abschneiden, da iOS mit längeren Zeichenketten nicht klar kommt (iOS only bug)" + else exportedDataText isLoadingExportedData = false } } FullscreenViewBase("Umsätze exportieren", onClosed = onClosed) { - Column { + Column(Modifier.fillMaxWidth()) { Text("Es gibt leider noch keinen \"Datei auswählen Dialog\", ist sehr schwierig plattformübergreifend umzusetzen, deshalb bitte folgenden Text kopieren und in eine Textdatei einfügen:") Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { @@ -68,8 +77,8 @@ fun ExportScreen(onClosed: () -> Unit) { } } else { Column(Modifier.verticalScroll().horizontalScroll()) { - SelectionContainer { - Text(exportedDataText, fontFamily = FontFamily.Monospace) + SelectionContainer(modifier = Modifier.fillMaxSize()) { + Text(exportedDataTextToDisplay, fontFamily = FontFamily.Monospace) } } }