Change account edit feature to theme 2

This commit is contained in:
Wolf-Martell Montwé 2024-04-22 16:54:35 +02:00
parent 267cfa9fe4
commit f3755502fb
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
9 changed files with 106 additions and 83 deletions

View file

@ -0,0 +1,51 @@
package app.k9mail.feature.account.edit.ui.server.settings.save
import androidx.compose.foundation.layout.PaddingValues
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 SaveServerSettingsContentPreview() {
PreviewWithThemes {
SaveServerSettingsContent(
state = SaveServerSettingsContract.State(
isLoading = false,
error = null,
),
contentPadding = PaddingValues(),
)
}
}
@Composable
@Preview(showBackground = true)
internal fun SaveServerSettingsContentLoadingPreview() {
PreviewWithThemes {
SaveServerSettingsContent(
state = SaveServerSettingsContract.State(
isLoading = true,
error = null,
),
contentPadding = PaddingValues(),
)
}
}
@Composable
@Preview(showBackground = true)
internal fun SaveServerSettingsContentErrorPreview() {
PreviewWithThemes {
SaveServerSettingsContent(
state = SaveServerSettingsContract.State(
isLoading = false,
error = SaveServerSettingsContract.Failure.SaveServerSettingsFailed(
message = "Error",
),
),
contentPadding = PaddingValues(),
)
}
}

View file

@ -0,0 +1,21 @@
package app.k9mail.feature.account.edit.ui.server.settings.save
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.edit.ui.server.settings.save.fake.FakeSaveServerSettingsViewModel
@Composable
@Preview(showBackground = true)
internal fun SaveServerSettingsScreenK9Preview() {
PreviewWithTheme {
SaveServerSettingsScreen(
title = "Incoming server settings",
onNext = {},
onBack = {},
viewModel = FakeSaveServerSettingsViewModel(
isIncoming = true,
),
)
}
}

View file

@ -7,12 +7,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
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.template.ResponsiveWidthContainer
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import app.k9mail.feature.account.common.ui.loadingerror.rememberContentLoadingErrorViewState
import app.k9mail.feature.account.edit.R
@ -49,48 +47,3 @@ fun SaveServerSettingsContent(
)
}
}
@Preview(showBackground = true)
@Composable
internal fun UpdateServerSettingsContentPreview() {
PreviewWithThemes {
SaveServerSettingsContent(
state = SaveServerSettingsContract.State(
isLoading = false,
error = null,
),
contentPadding = PaddingValues(),
)
}
}
@Preview(showBackground = true)
@Composable
internal fun UpdateServerSettingsContentLoadingPreview() {
PreviewWithThemes {
SaveServerSettingsContent(
state = SaveServerSettingsContract.State(
isLoading = true,
error = null,
),
contentPadding = PaddingValues(),
)
}
}
@Preview(showBackground = true)
@Composable
internal fun UpdateServerSettingsContentErrorPreview() {
PreviewWithThemes {
SaveServerSettingsContent(
state = SaveServerSettingsContract.State(
isLoading = false,
error = SaveServerSettingsContract.Failure.SaveServerSettingsFailed(
message = "Error",
),
),
contentPadding = PaddingValues(),
)
}
}

View file

@ -4,18 +4,14 @@ import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import app.k9mail.core.ui.compose.common.mvi.observe
import app.k9mail.core.ui.compose.designsystem.organism.TopAppBarWithBackButton
import app.k9mail.core.ui.compose.designsystem.template.Scaffold
import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.common.ui.WizardNavigationBar
import app.k9mail.feature.account.common.ui.WizardNavigationBarState
import app.k9mail.feature.account.edit.ui.server.settings.save.SaveServerSettingsContract.Effect
import app.k9mail.feature.account.edit.ui.server.settings.save.SaveServerSettingsContract.Event
import app.k9mail.feature.account.edit.ui.server.settings.save.SaveServerSettingsContract.ViewModel
import app.k9mail.feature.account.edit.ui.server.settings.save.fake.FakeSaveServerSettingsViewModel
@Composable
fun SaveServerSettingsScreen(
@ -69,33 +65,3 @@ fun SaveServerSettingsScreen(
)
}
}
@Composable
@Preview(showBackground = true)
internal fun SaveServerSettingsScreenK9Preview() {
K9Theme {
SaveServerSettingsScreen(
title = "Incoming server settings",
onNext = {},
onBack = {},
viewModel = FakeSaveServerSettingsViewModel(
isIncoming = true,
),
)
}
}
@Composable
@Preview(showBackground = true)
internal fun SaveServerSettingsScreenThunderbirdPreview() {
ThunderbirdTheme {
SaveServerSettingsScreen(
title = "Incoming server settings",
onNext = {},
onBack = {},
viewModel = FakeSaveServerSettingsViewModel(
isIncoming = true,
),
)
}
}

View file

@ -0,0 +1,18 @@
package app.k9mail.feature.account.edit.ui.server.settings.modify
import app.k9mail.core.common.domain.usecase.validation.ValidationResult
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsContract
class FakeIncomingServerSettingsValidator(
private val serverAnswer: ValidationResult = ValidationResult.Success,
private val portAnswer: ValidationResult = ValidationResult.Success,
private val usernameAnswer: ValidationResult = ValidationResult.Success,
private val passwordAnswer: ValidationResult = ValidationResult.Success,
private val imapPrefixAnswer: ValidationResult = ValidationResult.Success,
) : IncomingServerSettingsContract.Validator {
override fun validateServer(server: String): ValidationResult = serverAnswer
override fun validatePort(port: Long?): ValidationResult = portAnswer
override fun validateUsername(username: String): ValidationResult = usernameAnswer
override fun validatePassword(password: String): ValidationResult = passwordAnswer
override fun validateImapPrefix(imapPrefix: String): ValidationResult = imapPrefixAnswer
}

View file

@ -0,0 +1,16 @@
package app.k9mail.feature.account.edit.ui.server.settings.modify
import app.k9mail.core.common.domain.usecase.validation.ValidationResult
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract
class FakeOutgoingServerSettingsValidator(
private val serverAnswer: ValidationResult = ValidationResult.Success,
private val portAnswer: ValidationResult = ValidationResult.Success,
private val usernameAnswer: ValidationResult = ValidationResult.Success,
private val passwordAnswer: ValidationResult = ValidationResult.Success,
) : OutgoingServerSettingsContract.Validator {
override fun validateServer(server: String): ValidationResult = serverAnswer
override fun validatePort(port: Long?): ValidationResult = portAnswer
override fun validateUsername(username: String): ValidationResult = usernameAnswer
override fun validatePassword(password: String): ValidationResult = passwordAnswer
}

View file

@ -12,7 +12,6 @@ import app.k9mail.feature.account.common.domain.input.NumberInputField
import app.k9mail.feature.account.common.domain.input.StringInputField
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsContract.Event
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsContract.State
import app.k9mail.feature.account.server.settings.ui.incoming.fake.FakeIncomingServerSettingsValidator
import assertk.assertions.isEqualTo
import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.ServerSettings

View file

@ -12,7 +12,6 @@ import app.k9mail.feature.account.common.domain.input.NumberInputField
import app.k9mail.feature.account.common.domain.input.StringInputField
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract.Event
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract.State
import app.k9mail.feature.account.server.settings.ui.outgoing.fake.FakeOutgoingServerSettingsValidator
import assertk.assertions.isEqualTo
import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.ServerSettings