From 3bc87946c0a896a6a0414058f160042fc2b8bcb8 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 27 Aug 2024 12:24:19 +0200 Subject: [PATCH] Added Previews --- .../banking/ui/dialogs/EnterTanDialog.kt | 14 ----------- .../ui/dialogs/EnterTanDialogPreview.kt | 24 +++++++++++++++++++ .../kotlin/net/codinux/banking/ui/main.kt | 14 +++++++++++ 3 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt index 8cd467f..7474aa7 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt @@ -194,18 +194,4 @@ fun getTanMediumDisplayName(tanMedium: net.codinux.banking.client.model.tan.TanM } return tanMedium.mediumName ?: "" -} - - -@Preview -@Composable -fun EnterTanDialogPreview() { - val tanMethod = TanMethod("photoTan", TanMethodType.photoTan, "910", 6, AllowedTanFormat.Numeric) - val tanImage = TanImage("image/png", "") - - val customer = CustomerAccountViewInfo("10010010", "Ihr krasser Login Name", "Phantasie Bank") - - val tanChallenge = TanChallenge(TanChallengeType.Image, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethod.identifier, listOf(tanMethod), null, emptyList(), tanImage, null, customer) - - EnterTanDialog(TanChallengeReceived(tanChallenge, { })) { } } \ No newline at end of file diff --git a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt new file mode 100644 index 0000000..ef85212 --- /dev/null +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialogPreview.kt @@ -0,0 +1,24 @@ +package net.codinux.banking.ui.dialogs + +import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.runtime.Composable +import net.codinux.banking.client.model.CustomerAccountViewInfo +import net.codinux.banking.client.model.tan.* +import net.codinux.banking.ui.model.TanChallengeReceived + +@Preview +@Composable +fun EnterTanDialogPreview() { +// val tanMethod = TanMethod("photoTan", TanMethodType.photoTan, "910", 6, AllowedTanFormat.Numeric) +// val tanImage = TanImage("image/png", "") +// +// val customer = CustomerAccountViewInfo("10010010", "Ihr krasser Login Name", "Phantasie Bank") +// +// val tanChallenge = TanChallenge(TanChallengeType.Image, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethod.identifier, listOf(tanMethod), null, emptyList(), tanImage, null, customer) + + val tanMethods = listOf(TanMethod("Zeig mich an", TanMethodType.AppTan, "902")) + val customer = CustomerAccountViewInfo("12345678", "SupiDupiNutzer", "Abzockbank") + val tanChallenge = TanChallenge(TanChallengeType.EnterTan, ActionRequiringTan.GetAccountInfo, "Geben Sie die TAN ein", tanMethods.first().identifier, tanMethods, customer = customer) + + EnterTanDialog(TanChallengeReceived(tanChallenge) { }) { } +} \ No newline at end of file diff --git a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt index d9e03a7..1995ea7 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt @@ -1,5 +1,7 @@ package net.codinux.banking.ui +import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp @@ -8,7 +10,11 @@ import app.cash.sqldelight.async.coroutines.synchronous import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver import bankmeister.composeapp.generated.resources.AppIcon_svg import bankmeister.composeapp.generated.resources.Res +import kotlinx.datetime.LocalDate +import net.codinux.banking.client.model.AccountTransaction +import net.codinux.banking.client.model.Amount import net.codinux.banking.dataaccess.BankmeisterDb +import net.codinux.banking.dataaccess.InMemoryBankingRepository import net.codinux.banking.ui.config.DI import net.codinux.log.Log import org.jetbrains.compose.resources.painterResource @@ -28,4 +34,12 @@ fun main() = application { App() } +} + +@Preview +@Composable +fun AppPreview() { + DI.setRepository(InMemoryBankingRepository(listOf(AccountTransaction(Amount("12.34"), "EUR", "Lohn", LocalDate(2024, 7, 5), LocalDate(2024, 6, 15), "Dein Boss")))) + + App() } \ No newline at end of file