Cleanup account options
This commit is contained in:
parent
5c076d4f69
commit
ece413d9a2
2 changed files with 9 additions and 24 deletions
|
@ -1,10 +1,8 @@
|
|||
package app.k9mail.feature.account.setup.ui.options
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import app.k9mail.core.ui.compose.common.DevicePreviews
|
||||
import app.k9mail.core.ui.compose.common.mvi.observe
|
||||
|
@ -25,15 +23,10 @@ internal fun AccountOptionsScreen(
|
|||
viewModel: ViewModel,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val (state, dispatch) = viewModel.observe { effect ->
|
||||
when (effect) {
|
||||
Effect.NavigateBack -> onBack()
|
||||
Effect.NavigateNext -> {
|
||||
Toast.makeText(context, "Input is valid", Toast.LENGTH_SHORT).show() // TODO remove
|
||||
onNext()
|
||||
}
|
||||
Effect.NavigateNext -> onNext()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,6 @@ import app.k9mail.core.common.domain.usecase.validation.ValidationResult
|
|||
import app.k9mail.core.ui.compose.common.mvi.BaseViewModel
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Effect
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnAccountNameChanged
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnBackClicked
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnCheckFrequencyChanged
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnDisplayNameChanged
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnEmailSignatureChanged
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnMessageDisplayCountChanged
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnNextClicked
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event.OnShowNotificationChanged
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.State
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Validator
|
||||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.ViewModel
|
||||
|
@ -29,44 +21,44 @@ internal class AccountOptionsViewModel(
|
|||
|
||||
override fun event(event: Event) {
|
||||
when (event) {
|
||||
is OnAccountNameChanged -> updateState { state ->
|
||||
is Event.OnAccountNameChanged -> updateState { state ->
|
||||
state.copy(
|
||||
accountName = state.accountName.updateValue(event.accountName),
|
||||
)
|
||||
}
|
||||
|
||||
is OnDisplayNameChanged -> updateState {
|
||||
is Event.OnDisplayNameChanged -> updateState {
|
||||
it.copy(
|
||||
displayName = it.displayName.updateValue(event.displayName),
|
||||
)
|
||||
}
|
||||
|
||||
is OnEmailSignatureChanged -> updateState {
|
||||
is Event.OnEmailSignatureChanged -> updateState {
|
||||
it.copy(
|
||||
emailSignature = it.emailSignature.updateValue(event.emailSignature),
|
||||
)
|
||||
}
|
||||
|
||||
is OnCheckFrequencyChanged -> updateState {
|
||||
is Event.OnCheckFrequencyChanged -> updateState {
|
||||
it.copy(
|
||||
checkFrequency = event.checkFrequency,
|
||||
)
|
||||
}
|
||||
|
||||
is OnMessageDisplayCountChanged -> updateState { state ->
|
||||
is Event.OnMessageDisplayCountChanged -> updateState { state ->
|
||||
state.copy(
|
||||
messageDisplayCount = event.messageDisplayCount,
|
||||
)
|
||||
}
|
||||
|
||||
is OnShowNotificationChanged -> updateState { state ->
|
||||
is Event.OnShowNotificationChanged -> updateState { state ->
|
||||
state.copy(
|
||||
showNotification = event.showNotification,
|
||||
)
|
||||
}
|
||||
|
||||
OnNextClicked -> submit()
|
||||
OnBackClicked -> navigateBack()
|
||||
Event.OnNextClicked -> submit()
|
||||
Event.OnBackClicked -> navigateBack()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue