Change IncomingFormItems to only add protocol when interaction mode is create

This commit is contained in:
Wolf-Martell Montwé 2023-10-12 17:00:34 +02:00
parent c9003a5386
commit e898296d58
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
3 changed files with 18 additions and 8 deletions

View file

@ -17,12 +17,14 @@ 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.feature.account.common.domain.entity.InteractionMode
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.content.incomingFormItems
@Composable
internal fun IncomingServerSettingsContent(
mode: InteractionMode,
state: State,
onEvent: (Event) -> Unit,
contentPadding: PaddingValues,
@ -45,6 +47,7 @@ internal fun IncomingServerSettingsContent(
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
) {
incomingFormItems(
mode = mode,
state = state,
onEvent = onEvent,
resources = resources,
@ -58,6 +61,7 @@ internal fun IncomingServerSettingsContent(
internal fun IncomingServerSettingsContentK9Preview() {
K9Theme {
IncomingServerSettingsContent(
mode = InteractionMode.Create,
onEvent = { },
state = State(),
contentPadding = PaddingValues(),
@ -70,6 +74,7 @@ internal fun IncomingServerSettingsContentK9Preview() {
internal fun IncomingServerSettingsContentThunderbirdPreview() {
ThunderbirdTheme {
IncomingServerSettingsContent(
mode = InteractionMode.Create,
onEvent = { },
state = State(),
contentPadding = PaddingValues(),

View file

@ -64,6 +64,7 @@ fun IncomingServerSettingsScreen(
modifier = modifier,
) { innerPadding ->
IncomingServerSettingsContent(
mode = viewModel.mode,
onEvent = { dispatch(it) },
state = state.value,
contentPadding = innerPadding,

View file

@ -13,6 +13,7 @@ import app.k9mail.core.ui.compose.designsystem.molecule.input.TextInput
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity
import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType
import app.k9mail.feature.account.common.domain.entity.InteractionMode
import app.k9mail.feature.account.common.ui.item.defaultItemPadding
import app.k9mail.feature.account.server.settings.R
import app.k9mail.feature.account.server.settings.ui.common.ClientCertificateInput
@ -24,6 +25,7 @@ import app.k9mail.feature.account.server.settings.ui.incoming.isPasswordFieldVis
@Suppress("LongMethod")
internal fun LazyListScope.incomingFormItems(
mode: InteractionMode,
state: State,
onEvent: (Event) -> Unit,
resources: Resources,
@ -32,14 +34,16 @@ internal fun LazyListScope.incomingFormItems(
Spacer(modifier = Modifier.requiredHeight(MainTheme.sizes.smaller))
}
item {
SelectInput(
options = IncomingProtocolType.all(),
selectedOption = state.protocolType,
onOptionChange = { onEvent(Event.ProtocolTypeChanged(it)) },
label = stringResource(id = R.string.account_server_settings_protocol_type_label),
contentPadding = defaultItemPadding(),
)
if (mode == InteractionMode.Create) {
item {
SelectInput(
options = IncomingProtocolType.all(),
selectedOption = state.protocolType,
onOptionChange = { onEvent(Event.ProtocolTypeChanged(it)) },
label = stringResource(id = R.string.account_server_settings_protocol_type_label),
contentPadding = defaultItemPadding(),
)
}
}
item {