Move onBack method below onNext

This commit is contained in:
Wolf-Martell Montwé 2023-07-31 16:36:04 +02:00
parent 92e949c299
commit 9d8e54683b
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
2 changed files with 30 additions and 31 deletions

View file

@ -62,35 +62,6 @@ class AccountSetupViewModel(
onNext()
}
private fun onBack() {
when (state.value.setupStep) {
SetupStep.AUTO_CONFIG -> navigateBack()
SetupStep.INCOMING_CONFIG -> changeToSetupStep(SetupStep.AUTO_CONFIG)
SetupStep.INCOMING_VALIDATION -> {
if (state.value.isAutomaticConfig) {
changeToSetupStep(SetupStep.AUTO_CONFIG)
} else {
changeToSetupStep(SetupStep.INCOMING_CONFIG)
}
}
SetupStep.OUTGOING_CONFIG -> changeToSetupStep(SetupStep.INCOMING_CONFIG)
SetupStep.OUTGOING_VALIDATION -> {
if (state.value.isAutomaticConfig) {
changeToSetupStep(SetupStep.AUTO_CONFIG)
} else {
changeToSetupStep(SetupStep.OUTGOING_CONFIG)
}
}
SetupStep.OPTIONS -> if (state.value.isAutomaticConfig) {
changeToSetupStep(SetupStep.AUTO_CONFIG)
} else {
changeToSetupStep(SetupStep.OUTGOING_CONFIG)
}
}
}
private fun onNext() {
when (state.value.setupStep) {
SetupStep.AUTO_CONFIG -> {
@ -129,6 +100,35 @@ class AccountSetupViewModel(
}
}
private fun onBack() {
when (state.value.setupStep) {
SetupStep.AUTO_CONFIG -> navigateBack()
SetupStep.INCOMING_CONFIG -> changeToSetupStep(SetupStep.AUTO_CONFIG)
SetupStep.INCOMING_VALIDATION -> {
if (state.value.isAutomaticConfig) {
changeToSetupStep(SetupStep.AUTO_CONFIG)
} else {
changeToSetupStep(SetupStep.INCOMING_CONFIG)
}
}
SetupStep.OUTGOING_CONFIG -> changeToSetupStep(SetupStep.INCOMING_CONFIG)
SetupStep.OUTGOING_VALIDATION -> {
if (state.value.isAutomaticConfig) {
changeToSetupStep(SetupStep.AUTO_CONFIG)
} else {
changeToSetupStep(SetupStep.OUTGOING_CONFIG)
}
}
SetupStep.OPTIONS -> if (state.value.isAutomaticConfig) {
changeToSetupStep(SetupStep.AUTO_CONFIG)
} else {
changeToSetupStep(SetupStep.OUTGOING_CONFIG)
}
}
}
private fun changeToSetupStep(setupStep: SetupStep) {
if (setupStep == SetupStep.AUTO_CONFIG) {
authStateStorage.updateAuthorizationState(authorizationState = null)

View file

@ -1,6 +1,5 @@
package app.k9mail.feature.account.setup.ui
import app.cash.turbine.testIn
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
import app.k9mail.autodiscovery.api.ImapServerSettings
import app.k9mail.autodiscovery.api.SmtpServerSettings
@ -218,7 +217,7 @@ class AccountSetupViewModelTest {
authStateStorage = authStateStorage,
initialState = initialState,
)
val turbines = turbinesWithInitialStateCheck(viewModel, initialState,)
val turbines = turbinesWithInitialStateCheck(viewModel, initialState)
viewModel.event(AccountSetupContract.Event.OnBack)