From fe3a97377f2716d622f4a517a993ef94f609ec27 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 15 Oct 2024 10:18:40 +0200 Subject: [PATCH] Showing MessageLog in FeedbackScreen --- .../banking/ui/appskeleton/SideMenuContent.kt | 10 ++++ .../banking/ui/composables/StateHandler.kt | 5 ++ .../banking/ui/screens/FeedbackScreen.kt | 60 +++++++++++++++++++ .../net/codinux/banking/ui/state/UiState.kt | 2 + 4 files changed, 77 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FeedbackScreen.kt diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt index 777830c..61d8a12 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.* import androidx.compose.material.Icon import androidx.compose.material.Text import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.Message import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.SaveAs import androidx.compose.material.icons.outlined.Key @@ -120,6 +121,15 @@ fun SideMenuContent() { drawerState.close() } } + + NavigationMenuItem(itemModifier, "Feedback", textColor, horizontalPadding = ItemHorizontalPadding, + icon = { Icon(Icons.AutoMirrored.Filled.Message, "Feedback an die Entwickler geben", Modifier.size(iconSize), tint = textColor) }) { + uiState.showFeedbackScreen.value = true + + coroutineScope.launch { + drawerState.close() + } + } } } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt index 47f2798..4e14e92 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/StateHandler.kt @@ -23,6 +23,7 @@ fun StateHandler(uiState: UiState, snackbarHostState: SnackbarHostState) { val showBankAccountSettingsScreenForAccount by uiState.showBankAccountSettingsScreenForAccount.collectAsState() val showExportScreen by uiState.showExportScreen.collectAsState() + val showFeedbackScreen by uiState.showFeedbackScreen.collectAsState() val showProtectAppSettingsScreen by uiState.showProtectAppSettingsScreen.collectAsState() val tanChallengeReceived by uiState.tanChallengeReceived.collectAsState() @@ -68,6 +69,10 @@ fun StateHandler(uiState: UiState, snackbarHostState: SnackbarHostState) { ExportScreen { uiState.showExportScreen.value = false } } + if (showFeedbackScreen) { + FeedbackScreen { uiState.showFeedbackScreen.value = false } + } + if (showProtectAppSettingsScreen) { ProtectAppSettingsDialog(uiState.appSettings.value) { uiState.showProtectAppSettingsScreen.value = false } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FeedbackScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FeedbackScreen.kt new file mode 100644 index 0000000..77b10e2 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/FeedbackScreen.kt @@ -0,0 +1,60 @@ +package net.codinux.banking.ui.screens + +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.text.selection.SelectionContainer +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.runtime.* +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.font.FontFamily +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import net.codinux.banking.ui.IOorDefault +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.model.Config.NewLine + + +@Composable +fun FeedbackScreen(onClosed: () -> Unit) { + + val messageLog by remember { mutableStateOf(DI.bankingService.getMessageLog()) } + + val displayedLogEntries by remember { derivedStateOf { messageLog } } + + val displayedLogEntriesText by remember(displayedLogEntries) { + derivedStateOf { displayedLogEntries.map { + "${it.messageNumberString} ${it.type} ${it.messageCategory} ${it.messageSubCategory}${NewLine}${it.message}" + }.joinToString(NewLine + NewLine) } + } + + val clipboardManager = LocalClipboardManager.current + + val coroutineScope = rememberCoroutineScope() + + coroutineScope.launch(Dispatchers.IOorDefault) { + + } + + + FullscreenViewBase("Feedback", onClosed = onClosed) { + Column(Modifier.fillMaxWidth()) { + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + TextButton({ clipboardManager.setText(AnnotatedString(displayedLogEntriesText))}) { + Text("Kopieren", color = Colors.CodinuxSecondaryColor) + } + } + + Column(Modifier.verticalScroll().horizontalScroll()) { + SelectionContainer(modifier = Modifier.fillMaxSize()) { + Text(displayedLogEntriesText, fontFamily = FontFamily.Monospace) + } + } + } + } + +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt index cb3d74a..9ffd038 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/state/UiState.kt @@ -79,6 +79,8 @@ class UiState : ViewModel() { val showExportScreen = MutableStateFlow(false) + val showFeedbackScreen = MutableStateFlow(false) + val showProtectAppSettingsScreen = MutableStateFlow(false)