Add account outgoing config content ui

This commit is contained in:
Wolf-Martell Montwé 2023-06-02 12:15:57 +02:00
parent 69a2643b4e
commit fe86ef5878
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
3 changed files with 124 additions and 3 deletions

View file

@ -2,27 +2,42 @@ package app.k9mail.feature.account.setup.ui.outgoing
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import app.k9mail.core.ui.compose.common.DevicePreviews
import app.k9mail.core.ui.compose.designsystem.atom.text.TextBody1
import app.k9mail.core.ui.compose.designsystem.molecule.input.CheckboxInput
import app.k9mail.core.ui.compose.designsystem.molecule.input.NumberInput
import app.k9mail.core.ui.compose.designsystem.molecule.input.PasswordInput
import app.k9mail.core.ui.compose.designsystem.molecule.input.SelectInput
import app.k9mail.core.ui.compose.designsystem.molecule.input.TextInput
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.setup.R
import app.k9mail.feature.account.setup.domain.entity.ConnectionSecurity
import app.k9mail.feature.account.setup.ui.common.defaultItemPadding
import kotlinx.collections.immutable.persistentListOf
@Suppress("LongMethod")
@Composable
internal fun AccountOutgoingConfigContent(
contentPadding: PaddingValues,
modifier: Modifier = Modifier,
) {
val resources = LocalContext.current.resources
ResponsiveWidthContainer(
modifier = Modifier
.testTag("AccountOutgoingConfigContent")
@ -38,7 +53,89 @@ internal fun AccountOutgoingConfigContent(
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
) {
item {
TextBody1(text = "Outgoing Config")
Spacer(modifier = Modifier.requiredHeight(MainTheme.sizes.smaller))
}
item {
TextInput(
text = "",
onTextChange = { },
label = stringResource(id = R.string.account_setup_outgoing_config_server_label),
contentPadding = defaultItemPadding(),
)
}
item {
SelectInput(
options = ConnectionSecurity.all(),
optionToStringTransformation = { it.toResourceString(resources) },
selectedOption = ConnectionSecurity.DEFAULT,
onOptionChange = { },
label = stringResource(id = R.string.account_setup_outgoing_config_security_label),
contentPadding = defaultItemPadding(),
)
}
item {
NumberInput(
value = null,
onValueChange = { },
label = stringResource(id = R.string.account_setup_outgoing_config_port_label),
contentPadding = defaultItemPadding(),
)
}
item {
TextInput(
text = "",
onTextChange = { },
label = stringResource(id = R.string.account_setup_outgoing_config_username_label),
contentPadding = defaultItemPadding(),
)
}
item {
PasswordInput(
password = "",
onPasswordChange = { },
contentPadding = defaultItemPadding(),
)
}
item {
// TODO add client certificate support
SelectInput(
options = persistentListOf(
stringResource(
id = R.string.account_setup_outgoing_config_client_certificate_none_available,
),
),
optionToStringTransformation = { it },
selectedOption = stringResource(
id = R.string.account_setup_outgoing_config_client_certificate_none_available,
),
onOptionChange = {},
label = stringResource(id = R.string.account_setup_outgoing_config_client_certificate_label),
contentPadding = defaultItemPadding(),
)
}
item {
CheckboxInput(
text = stringResource(id = R.string.account_setup_outgoing_config_imap_namespace_label),
checked = false,
onCheckedChange = { },
contentPadding = defaultItemPadding(),
)
}
item {
CheckboxInput(
text = stringResource(id = R.string.account_setup_outgoing_config_compression_label),
checked = false,
onCheckedChange = { },
contentPadding = defaultItemPadding(),
)
}
}
}

View file

@ -0,0 +1,13 @@
package app.k9mail.feature.account.setup.ui.outgoing
import android.content.res.Resources
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.domain.entity.ConnectionSecurity
internal fun ConnectionSecurity.toResourceString(resources: Resources): String {
return when (this) {
ConnectionSecurity.None -> resources.getString(R.string.account_setup_outgoing_config_security_none)
ConnectionSecurity.StartTLS -> resources.getString(R.string.account_setup_outgoing_config_security_start_tls)
ConnectionSecurity.TLS -> resources.getString(R.string.account_setup_outgoing_config_security_ssl)
}
}

View file

@ -10,8 +10,19 @@
<string name="account_setup_incoming_config_top_bar_title">Incoming server settings</string>
<string name="account_setup_outgoing_config_top_bar_title">Outgoing server settings</string>
<string name="account_setup_outgoing_config_server_label">Server</string>
<string name="account_setup_outgoing_config_security_label">Security</string>
<string name="account_setup_outgoing_config_security_none">None</string>
<string name="account_setup_outgoing_config_security_ssl">SSL/TLS</string>
<string name="account_setup_outgoing_config_security_start_tls">StartTLS</string>
<string name="account_setup_outgoing_config_port_label">Port</string>
<string name="account_setup_outgoing_config_username_label">Username</string>
<string name="account_setup_outgoing_config_client_certificate_label">Client certificate</string>
<string name="account_setup_outgoing_config_client_certificate_none_available">None available</string>
<string name="account_setup_outgoing_config_imap_namespace_label">Auto-detect IMAP namespace</string>
<string name="account_setup_outgoing_config_compression_label">Use compression</string>
<string name="account_setup_options_top_bar_title">Account options</string>
<string name="account_setup_options_top_bar_title">Account options</string>
<string name="account_setup_options_section_display_options">Display options</string>
<string name="account_setup_options_account_name_label">Account name</string>
<string name="account_setup_options_account_name_error_blank">Account name can\'t be blank.</string>