From 742943c294219075977b8f3489dce259b9e1ddb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Thu, 12 Oct 2023 17:00:34 +0200 Subject: [PATCH] Change IncomingFormItems to only add protocol when interaction mode is create --- .../incoming/IncomingServerSettingsContent.kt | 5 +++++ .../incoming/IncomingServerSettingsScreen.kt | 1 + .../ui/incoming/content/IncomingFormItems.kt | 20 +++++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsContent.kt b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsContent.kt index 85957281454..83e39c27f2b 100644 --- a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsContent.kt +++ b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsContent.kt @@ -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(), diff --git a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsScreen.kt b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsScreen.kt index 6407a5b6d19..50b36dee6c7 100644 --- a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsScreen.kt +++ b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/IncomingServerSettingsScreen.kt @@ -64,6 +64,7 @@ fun IncomingServerSettingsScreen( modifier = modifier, ) { innerPadding -> IncomingServerSettingsContent( + mode = viewModel.mode, onEvent = { dispatch(it) }, state = state.value, contentPadding = innerPadding, diff --git a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/content/IncomingFormItems.kt b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/content/IncomingFormItems.kt index 94c5364b608..ce72ce3b6a6 100644 --- a/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/content/IncomingFormItems.kt +++ b/feature/account/server/settings/src/main/kotlin/app/k9mail/feature/account/server/settings/ui/incoming/content/IncomingFormItems.kt @@ -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 {