From ac19c2765c9ba3d8ac85b4b0170b5cc1361de758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Wed, 24 Apr 2024 13:40:08 +0200 Subject: [PATCH] Change account setup autodiscovery feature to theme 2 --- .../AccountAutoDiscoveryContentPreview.kt | 98 +++++++++++++++++++ .../AccountAutoDiscoveryScreenPreview.kt | 25 +++++ .../fake/FakeAutoDiscoveryResult.kt | 29 ++++++ .../AutoDiscoveryResultApprovalViewPreview.kt | 20 ++++ .../AutoDiscoveryResultBodyViewPreview.kt | 17 ++++ .../AutoDiscoveryResultHeaderViewPreview.kt | 60 ++++++++++++ .../view/AutoDiscoveryResultViewPreview.kt | 28 ++++++ .../AutoDiscoveryServerSettingsViewPreview.kt | 62 ++++++++++++ .../AccountAutoDiscoveryContent.kt | 30 +----- .../AccountAutoDiscoveryScreen.kt | 40 -------- .../view/AutoDiscoveryResultApprovalView.kt | 18 +--- .../view/AutoDiscoveryResultBodyView.kt | 36 +------ .../view/AutoDiscoveryResultHeaderView.kt | 59 +---------- .../view/AutoDiscoveryResultView.kt | 66 +------------ .../view/AutoDiscoveryServerSettingsView.kt | 60 +----------- 15 files changed, 345 insertions(+), 303 deletions(-) create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContentPreview.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreenPreview.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/fake/FakeAutoDiscoveryResult.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalViewPreview.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyViewPreview.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderViewPreview.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultViewPreview.kt create mode 100644 feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsViewPreview.kt diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContentPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContentPreview.kt new file mode 100644 index 000000000..07aa1a250 --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContentPreview.kt @@ -0,0 +1,98 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery + +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme +import app.k9mail.feature.account.common.domain.input.StringInputField +import app.k9mail.feature.account.oauth.ui.preview.PreviewAccountOAuthViewModel +import app.k9mail.feature.account.server.validation.ui.fake.FakeAccountOAuthViewModel +import app.k9mail.feature.account.setup.ui.autodiscovery.fake.fakeAutoDiscoveryResultSettings + +@Composable +@Preview(showBackground = true) +internal fun AccountAutoDiscoveryContentPreview() { + PreviewWithTheme { + AccountAutoDiscoveryContent( + state = AccountAutoDiscoveryContract.State(), + onEvent = {}, + oAuthViewModel = FakeAccountOAuthViewModel(), + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AccountAutoDiscoveryContentEmailPreview() { + PreviewWithTheme { + AccountAutoDiscoveryContent( + state = AccountAutoDiscoveryContract.State( + emailAddress = StringInputField(value = "test@example.com"), + ), + onEvent = {}, + oAuthViewModel = FakeAccountOAuthViewModel(), + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AccountAutoDiscoveryContentPasswordPreview() { + PreviewWithTheme { + AccountAutoDiscoveryContent( + state = AccountAutoDiscoveryContract.State( + configStep = AccountAutoDiscoveryContract.ConfigStep.PASSWORD, + emailAddress = StringInputField(value = "test@example.com"), + autoDiscoverySettings = fakeAutoDiscoveryResultSettings(isTrusted = true), + ), + onEvent = {}, + oAuthViewModel = PreviewAccountOAuthViewModel(), + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AccountAutoDiscoveryContentPasswordUntrustedSettingsPreview() { + PreviewWithTheme { + AccountAutoDiscoveryContent( + state = AccountAutoDiscoveryContract.State( + configStep = AccountAutoDiscoveryContract.ConfigStep.PASSWORD, + emailAddress = StringInputField(value = "test@example.com"), + autoDiscoverySettings = fakeAutoDiscoveryResultSettings(isTrusted = false), + ), + onEvent = {}, + oAuthViewModel = PreviewAccountOAuthViewModel(), + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AccountAutoDiscoveryContentPasswordNoSettingsPreview() { + PreviewWithTheme { + AccountAutoDiscoveryContent( + state = AccountAutoDiscoveryContract.State( + configStep = AccountAutoDiscoveryContract.ConfigStep.PASSWORD, + emailAddress = StringInputField(value = "test@example.com"), + ), + onEvent = {}, + oAuthViewModel = FakeAccountOAuthViewModel(), + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AccountAutoDiscoveryContentOAuthPreview() { + PreviewWithTheme { + AccountAutoDiscoveryContent( + state = AccountAutoDiscoveryContract.State( + configStep = AccountAutoDiscoveryContract.ConfigStep.OAUTH, + emailAddress = StringInputField(value = "test@example.com"), + autoDiscoverySettings = fakeAutoDiscoveryResultSettings(isTrusted = true), + ), + onEvent = {}, + oAuthViewModel = FakeAccountOAuthViewModel(), + ) + } +} diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreenPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreenPreview.kt new file mode 100644 index 000000000..b2ae952fd --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreenPreview.kt @@ -0,0 +1,25 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery + +import androidx.compose.runtime.Composable +import app.k9mail.autodiscovery.api.AutoDiscoveryResult +import app.k9mail.core.ui.compose.common.annotation.PreviewDevicesWithBackground +import app.k9mail.core.ui.compose.designsystem.PreviewWithTheme +import app.k9mail.feature.account.common.ui.fake.FakeAccountStateRepository +import app.k9mail.feature.account.server.validation.ui.fake.FakeAccountOAuthViewModel + +@Composable +@PreviewDevicesWithBackground +internal fun AccountAutoDiscoveryScreenK9Preview() { + PreviewWithTheme { + AccountAutoDiscoveryScreen( + onNext = {}, + onBack = {}, + viewModel = AccountAutoDiscoveryViewModel( + validator = AccountAutoDiscoveryValidator(), + getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound }, + accountStateRepository = FakeAccountStateRepository(), + oAuthViewModel = FakeAccountOAuthViewModel(), + ), + ) + } +} diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/fake/FakeAutoDiscoveryResult.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/fake/FakeAutoDiscoveryResult.kt new file mode 100644 index 000000000..3a62d920d --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/fake/FakeAutoDiscoveryResult.kt @@ -0,0 +1,29 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery.fake + +import app.k9mail.autodiscovery.api.AuthenticationType +import app.k9mail.autodiscovery.api.AutoDiscoveryResult +import app.k9mail.autodiscovery.api.ConnectionSecurity +import app.k9mail.autodiscovery.api.ImapServerSettings +import app.k9mail.autodiscovery.api.SmtpServerSettings +import app.k9mail.core.common.net.toHostname +import app.k9mail.core.common.net.toPort + +internal fun fakeAutoDiscoveryResultSettings(isTrusted: Boolean) = + AutoDiscoveryResult.Settings( + incomingServerSettings = ImapServerSettings( + hostname = "imap.example.com".toHostname(), + port = 993.toPort(), + connectionSecurity = ConnectionSecurity.TLS, + authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), + username = "", + ), + outgoingServerSettings = SmtpServerSettings( + hostname = "smtp.example.com".toHostname(), + port = 465.toPort(), + connectionSecurity = ConnectionSecurity.TLS, + authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), + username = "", + ), + isTrusted = isTrusted, + source = "preview", + ) diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalViewPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalViewPreview.kt new file mode 100644 index 000000000..325d1ad69 --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalViewPreview.kt @@ -0,0 +1,20 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes +import app.k9mail.feature.account.common.domain.input.BooleanInputField + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultApprovalViewPreview() { + PreviewWithThemes { + AutoDiscoveryResultApprovalView( + approvalState = BooleanInputField( + value = true, + isValid = true, + ), + onApprovalChange = {}, + ) + } +} diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyViewPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyViewPreview.kt new file mode 100644 index 000000000..f85570d1a --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyViewPreview.kt @@ -0,0 +1,17 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes +import app.k9mail.feature.account.setup.ui.autodiscovery.fake.fakeAutoDiscoveryResultSettings + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultBodyViewPreview() { + PreviewWithThemes { + AutoDiscoveryResultBodyView( + settings = fakeAutoDiscoveryResultSettings(isTrusted = true), + onEditConfigurationClick = {}, + ) + } +} diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderViewPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderViewPreview.kt new file mode 100644 index 000000000..ea2d77054 --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderViewPreview.kt @@ -0,0 +1,60 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultHeaderViewTrustedCollapsedPreview() { + PreviewWithThemes { + AutoDiscoveryResultHeaderView( + state = AutoDiscoveryResultHeaderState.Trusted, + isExpanded = true, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultHeaderViewTrustedExpandedPreview() { + PreviewWithThemes { + AutoDiscoveryResultHeaderView( + state = AutoDiscoveryResultHeaderState.Trusted, + isExpanded = false, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultHeaderViewUntrustedCollapsedPreview() { + PreviewWithThemes { + AutoDiscoveryResultHeaderView( + state = AutoDiscoveryResultHeaderState.Untrusted, + isExpanded = true, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultHeaderViewUntrustedExpandedPreview() { + PreviewWithThemes { + AutoDiscoveryResultHeaderView( + state = AutoDiscoveryResultHeaderState.Untrusted, + isExpanded = false, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultHeaderNoSettingsPreview() { + PreviewWithThemes { + AutoDiscoveryResultHeaderView( + state = AutoDiscoveryResultHeaderState.NoSettings, + isExpanded = false, + ) + } +} diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultViewPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultViewPreview.kt new file mode 100644 index 000000000..4540d8812 --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultViewPreview.kt @@ -0,0 +1,28 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes +import app.k9mail.feature.account.setup.ui.autodiscovery.fake.fakeAutoDiscoveryResultSettings + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultViewTrustedPreview() { + PreviewWithThemes { + AutoDiscoveryResultView( + settings = fakeAutoDiscoveryResultSettings(isTrusted = true), + onEditConfigurationClick = {}, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryResultViewUntrustedPreview() { + PreviewWithThemes { + AutoDiscoveryResultView( + settings = fakeAutoDiscoveryResultSettings(isTrusted = false), + onEditConfigurationClick = {}, + ) + } +} diff --git a/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsViewPreview.kt b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsViewPreview.kt new file mode 100644 index 000000000..c7cbb4520 --- /dev/null +++ b/feature/account/setup/src/debug/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsViewPreview.kt @@ -0,0 +1,62 @@ +package app.k9mail.feature.account.setup.ui.autodiscovery.view + +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import app.k9mail.autodiscovery.api.ConnectionSecurity +import app.k9mail.core.common.net.toHostname +import app.k9mail.core.ui.compose.designsystem.PreviewWithThemes + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryServerSettingsViewPreview() { + PreviewWithThemes { + AutoDiscoveryServerSettingsView( + protocolName = "IMAP", + serverHostname = "imap.example.com".toHostname(), + serverPort = 993, + connectionSecurity = ConnectionSecurity.TLS, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryServerSettingsViewOutgoingPreview() { + PreviewWithThemes { + AutoDiscoveryServerSettingsView( + protocolName = "IMAP", + serverHostname = "imap.example.com".toHostname(), + serverPort = 993, + connectionSecurity = ConnectionSecurity.TLS, + isIncoming = false, + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryServerSettingsViewWithUserPreview() { + PreviewWithThemes { + AutoDiscoveryServerSettingsView( + protocolName = "IMAP", + serverHostname = "imap.example.com".toHostname(), + serverPort = 993, + connectionSecurity = ConnectionSecurity.TLS, + username = "username", + ) + } +} + +@Composable +@Preview(showBackground = true) +internal fun AutoDiscoveryServerSettingsViewWithIpAddressPreview() { + PreviewWithThemes { + AutoDiscoveryServerSettingsView( + protocolName = "IMAP", + serverHostname = "127.0.0.1".toHostname(), + serverPort = 993, + connectionSecurity = ConnectionSecurity.TLS, + username = "username", + ) + } +} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt index e82452b3c..c379bee6a 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt @@ -15,23 +15,19 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource -import app.k9mail.core.ui.compose.common.annotation.PreviewDevicesWithBackground import app.k9mail.core.ui.compose.designsystem.molecule.ContentLoadingErrorView import app.k9mail.core.ui.compose.designsystem.molecule.ErrorView import app.k9mail.core.ui.compose.designsystem.molecule.LoadingView import app.k9mail.core.ui.compose.designsystem.molecule.input.EmailAddressInput import app.k9mail.core.ui.compose.designsystem.molecule.input.PasswordInput import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer -import app.k9mail.core.ui.compose.theme.K9Theme -import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.ThunderbirdTheme +import app.k9mail.core.ui.compose.theme2.MainTheme import app.k9mail.feature.account.common.ui.AppTitleTopHeader import app.k9mail.feature.account.common.ui.WizardNavigationBar import app.k9mail.feature.account.common.ui.WizardNavigationBarState import app.k9mail.feature.account.common.ui.loadingerror.rememberContentLoadingErrorViewState import app.k9mail.feature.account.oauth.ui.AccountOAuthContract import app.k9mail.feature.account.oauth.ui.AccountOAuthView -import app.k9mail.feature.account.oauth.ui.preview.PreviewAccountOAuthViewModel import app.k9mail.feature.account.setup.R import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State @@ -177,27 +173,3 @@ internal fun ContentView( } } } - -@Composable -@PreviewDevicesWithBackground -internal fun AccountAutoDiscoveryContentK9Preview() { - K9Theme { - AccountAutoDiscoveryContent( - state = State(), - onEvent = {}, - oAuthViewModel = PreviewAccountOAuthViewModel(), - ) - } -} - -@Composable -@PreviewDevicesWithBackground -internal fun AccountAutoDiscoveryContentThunderbirdPreview() { - ThunderbirdTheme { - AccountAutoDiscoveryContent( - state = State(), - onEvent = {}, - oAuthViewModel = PreviewAccountOAuthViewModel(), - ) - } -} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreen.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreen.kt index e46a9398e..041292bb7 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreen.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryScreen.kt @@ -3,13 +3,7 @@ package app.k9mail.feature.account.setup.ui.autodiscovery import androidx.activity.compose.BackHandler import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import app.k9mail.autodiscovery.api.AutoDiscoveryResult -import app.k9mail.core.ui.compose.common.annotation.PreviewDevicesWithBackground import app.k9mail.core.ui.compose.common.mvi.observe -import app.k9mail.core.ui.compose.theme.K9Theme -import app.k9mail.core.ui.compose.theme.ThunderbirdTheme -import app.k9mail.feature.account.common.ui.preview.PreviewAccountStateRepository -import app.k9mail.feature.account.oauth.ui.preview.PreviewAccountOAuthViewModel import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.AutoDiscoveryUiResult import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event @@ -40,37 +34,3 @@ internal fun AccountAutoDiscoveryScreen( modifier = modifier, ) } - -@Composable -@PreviewDevicesWithBackground -internal fun AccountAutoDiscoveryScreenK9Preview() { - K9Theme { - AccountAutoDiscoveryScreen( - onNext = {}, - onBack = {}, - viewModel = AccountAutoDiscoveryViewModel( - validator = AccountAutoDiscoveryValidator(), - getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound }, - accountStateRepository = PreviewAccountStateRepository(), - oAuthViewModel = PreviewAccountOAuthViewModel(), - ), - ) - } -} - -@Composable -@PreviewDevicesWithBackground -internal fun AccountAutoDiscoveryScreenThunderbirdPreview() { - ThunderbirdTheme { - AccountAutoDiscoveryScreen( - onNext = { }, - onBack = {}, - viewModel = AccountAutoDiscoveryViewModel( - validator = AccountAutoDiscoveryValidator(), - getAutoDiscovery = { AutoDiscoveryResult.NoUsableSettingsFound }, - accountStateRepository = PreviewAccountStateRepository(), - oAuthViewModel = PreviewAccountOAuthViewModel(), - ), - ) - } -} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalView.kt index ebfdfa28a..87d5e31aa 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultApprovalView.kt @@ -7,10 +7,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import app.k9mail.core.ui.compose.designsystem.molecule.input.CheckboxInput -import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.PreviewWithThemes +import app.k9mail.core.ui.compose.theme2.MainTheme import app.k9mail.feature.account.common.domain.input.BooleanInputField import app.k9mail.feature.account.setup.R import app.k9mail.feature.account.setup.ui.autodiscovery.toAutoDiscoveryValidationErrorString @@ -34,17 +32,3 @@ internal fun AutoDiscoveryResultApprovalView( contentPadding = PaddingValues(), ) } - -@Preview(showBackground = true) -@Composable -internal fun AutoDiscoveryResultApprovalViewPreview() { - PreviewWithThemes { - AutoDiscoveryResultApprovalView( - approvalState = BooleanInputField( - value = true, - isValid = true, - ), - onApprovalChange = {}, - ) - } -} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyView.kt index 9efb7e6ce..855670e35 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultBodyView.kt @@ -10,18 +10,12 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview -import app.k9mail.autodiscovery.api.AuthenticationType import app.k9mail.autodiscovery.api.AutoDiscoveryResult -import app.k9mail.autodiscovery.api.ConnectionSecurity import app.k9mail.autodiscovery.api.ImapServerSettings import app.k9mail.autodiscovery.api.SmtpServerSettings -import app.k9mail.core.common.net.toHostname -import app.k9mail.core.common.net.toPort import app.k9mail.core.ui.compose.designsystem.atom.button.ButtonText import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodyMedium -import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.PreviewWithThemes +import app.k9mail.core.ui.compose.theme2.MainTheme import app.k9mail.feature.account.setup.R @Composable @@ -99,31 +93,3 @@ internal fun EditConfigurationButton( ) } } - -@Preview -@Composable -internal fun AutoDiscoveryResultBodyViewPreview() { - PreviewWithThemes { - AutoDiscoveryResultBodyView( - settings = AutoDiscoveryResult.Settings( - incomingServerSettings = ImapServerSettings( - hostname = "imap.example.com".toHostname(), - port = 993.toPort(), - connectionSecurity = ConnectionSecurity.TLS, - authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), - username = "", - ), - outgoingServerSettings = SmtpServerSettings( - hostname = "smtp.example.com".toHostname(), - port = 465.toPort(), - connectionSecurity = ConnectionSecurity.TLS, - authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), - username = "", - ), - isTrusted = true, - source = "preview", - ), - onEditConfigurationClick = {}, - ) - } -} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderView.kt index a87556bc0..6bd8d4311 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultHeaderView.kt @@ -10,13 +10,11 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import app.k9mail.core.ui.compose.designsystem.atom.icon.Icon import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodyMedium import app.k9mail.core.ui.compose.designsystem.atom.text.TextTitleLarge -import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.PreviewWithThemes +import app.k9mail.core.ui.compose.theme2.MainTheme @Suppress("LongMethod") @Composable @@ -72,58 +70,3 @@ private fun selectColor(state: AutoDiscoveryResultHeaderState): Color { AutoDiscoveryResultHeaderState.Untrusted -> MainTheme.colors.warning } } - -@Preview -@Composable -internal fun AutoDiscoveryResultHeaderViewTrustedCollapsedPreview() { - PreviewWithThemes { - AutoDiscoveryResultHeaderView( - state = AutoDiscoveryResultHeaderState.Trusted, - isExpanded = true, - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryResultHeaderViewTrustedExpandedPreview() { - PreviewWithThemes { - AutoDiscoveryResultHeaderView( - state = AutoDiscoveryResultHeaderState.Trusted, - isExpanded = false, - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryResultHeaderViewUntrustedCollapsedPreview() { - PreviewWithThemes { - AutoDiscoveryResultHeaderView( - state = AutoDiscoveryResultHeaderState.Untrusted, - isExpanded = true, - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryResultHeaderViewUntrustedExpandedPreview() { - PreviewWithThemes { - AutoDiscoveryResultHeaderView( - state = AutoDiscoveryResultHeaderState.Untrusted, - isExpanded = false, - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryResultHeaderNoSettingsPreview() { - PreviewWithThemes { - AutoDiscoveryResultHeaderView( - state = AutoDiscoveryResultHeaderState.NoSettings, - isExpanded = false, - ) - } -} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultView.kt index 3ab9667b9..e1b2ce87f 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryResultView.kt @@ -10,18 +10,10 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import app.k9mail.autodiscovery.api.AuthenticationType import app.k9mail.autodiscovery.api.AutoDiscoveryResult -import app.k9mail.autodiscovery.api.ConnectionSecurity -import app.k9mail.autodiscovery.api.ImapServerSettings -import app.k9mail.autodiscovery.api.SmtpServerSettings -import app.k9mail.core.common.net.toHostname -import app.k9mail.core.common.net.toPort import app.k9mail.core.ui.compose.designsystem.atom.Surface -import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.PreviewWithThemes +import app.k9mail.core.ui.compose.theme2.MainTheme @Composable internal fun AutoDiscoveryResultView( @@ -72,59 +64,3 @@ internal fun AutoDiscoveryResultView( } } } - -@Preview(showBackground = true) -@Composable -internal fun AutoDiscoveryResultViewTrustedPreview() { - PreviewWithThemes { - AutoDiscoveryResultView( - settings = AutoDiscoveryResult.Settings( - incomingServerSettings = ImapServerSettings( - hostname = "imap.example.com".toHostname(), - port = 993.toPort(), - connectionSecurity = ConnectionSecurity.TLS, - authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), - username = "", - ), - outgoingServerSettings = SmtpServerSettings( - hostname = "smtp.example.com".toHostname(), - port = 465.toPort(), - connectionSecurity = ConnectionSecurity.TLS, - authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), - username = "", - ), - isTrusted = true, - source = "preview", - ), - onEditConfigurationClick = {}, - ) - } -} - -@Preview(showBackground = true) -@Composable -internal fun AutoDiscoveryResultViewUntrustedPreview() { - PreviewWithThemes { - AutoDiscoveryResultView( - settings = AutoDiscoveryResult.Settings( - incomingServerSettings = ImapServerSettings( - hostname = "imap.example.com".toHostname(), - port = 993.toPort(), - connectionSecurity = ConnectionSecurity.TLS, - authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), - username = "", - ), - outgoingServerSettings = SmtpServerSettings( - hostname = "smtp.example.com".toHostname(), - port = 465.toPort(), - connectionSecurity = ConnectionSecurity.TLS, - authenticationTypes = listOf(AuthenticationType.PasswordEncrypted), - username = "", - ), - isTrusted = false, - source = "preview", - ), - onEditConfigurationClick = {}, - ) - } -} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt index 44d7eb43c..3976538b2 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt @@ -15,17 +15,14 @@ import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.withStyle -import androidx.compose.ui.tooling.preview.Preview import app.k9mail.autodiscovery.api.ConnectionSecurity import app.k9mail.core.common.net.Hostname import app.k9mail.core.common.net.isIpAddress -import app.k9mail.core.common.net.toHostname import app.k9mail.core.ui.compose.designsystem.atom.icon.Icon import app.k9mail.core.ui.compose.designsystem.atom.icon.Icons import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodyLarge import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodyMedium -import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.PreviewWithThemes +import app.k9mail.core.ui.compose.theme2.MainTheme import app.k9mail.feature.account.setup.ui.autodiscovery.toAutoDiscoveryConnectionSecurityString @Composable @@ -116,58 +113,3 @@ private fun ServerSettingRow( ) } } - -@Preview -@Composable -internal fun AutoDiscoveryServerSettingsViewPreview() { - PreviewWithThemes { - AutoDiscoveryServerSettingsView( - protocolName = "IMAP", - serverHostname = "imap.example.com".toHostname(), - serverPort = 993, - connectionSecurity = ConnectionSecurity.TLS, - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryServerSettingsViewOutgoingPreview() { - PreviewWithThemes { - AutoDiscoveryServerSettingsView( - protocolName = "IMAP", - serverHostname = "imap.example.com".toHostname(), - serverPort = 993, - connectionSecurity = ConnectionSecurity.TLS, - isIncoming = false, - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryServerSettingsViewWithUserPreview() { - PreviewWithThemes { - AutoDiscoveryServerSettingsView( - protocolName = "IMAP", - serverHostname = "imap.example.com".toHostname(), - serverPort = 993, - connectionSecurity = ConnectionSecurity.TLS, - username = "username", - ) - } -} - -@Preview -@Composable -internal fun AutoDiscoveryServerSettingsViewWithIpAddressPreview() { - PreviewWithThemes { - AutoDiscoveryServerSettingsView( - protocolName = "IMAP", - serverHostname = "127.0.0.1".toHostname(), - serverPort = 993, - connectionSecurity = ConnectionSecurity.TLS, - username = "username", - ) - } -}