Skip to content

Commit

Permalink
Change IncomingFormItems to only add protocol when interaction mode i…
Browse files Browse the repository at this point in the history
…s create
  • Loading branch information
wmontwe committed Oct 12, 2023
1 parent 52cf0f3 commit 742943c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -45,6 +47,7 @@ internal fun IncomingServerSettingsContent(
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
) {
incomingFormItems(
mode = mode,
state = state,
onEvent = onEvent,
resources = resources,
Expand All @@ -58,6 +61,7 @@ internal fun IncomingServerSettingsContent(
internal fun IncomingServerSettingsContentK9Preview() {
K9Theme {
IncomingServerSettingsContent(
mode = InteractionMode.Create,
onEvent = { },
state = State(),
contentPadding = PaddingValues(),
Expand All @@ -70,6 +74,7 @@ internal fun IncomingServerSettingsContentK9Preview() {
internal fun IncomingServerSettingsContentThunderbirdPreview() {
ThunderbirdTheme {
IncomingServerSettingsContent(
mode = InteractionMode.Create,
onEvent = { },
state = State(),
contentPadding = PaddingValues(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fun IncomingServerSettingsScreen(
modifier = modifier,
) { innerPadding ->
IncomingServerSettingsContent(
mode = viewModel.mode,
onEvent = { dispatch(it) },
state = state.value,
contentPadding = innerPadding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 742943c

Please sign in to comment.