Add biometric password input to server settings form
This commit is contained in:
parent
dc1c8fd060
commit
566d2a72de
5 changed files with 78 additions and 5 deletions
|
@ -0,0 +1,63 @@
|
|||
package app.k9mail.feature.account.server.settings.ui.common
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import app.k9mail.core.ui.compose.designsystem.molecule.input.PasswordInput
|
||||
import app.k9mail.core.ui.compose.designsystem.molecule.input.inputContentPadding
|
||||
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
|
||||
import app.k9mail.feature.account.common.domain.entity.InteractionMode
|
||||
|
||||
@Composable
|
||||
fun ServerSettingsPasswordInput(
|
||||
mode: InteractionMode,
|
||||
onPasswordChange: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
password: String = "",
|
||||
isRequired: Boolean = false,
|
||||
errorMessage: String? = null,
|
||||
contentPadding: PaddingValues = inputContentPadding(),
|
||||
) {
|
||||
if (mode == InteractionMode.Create) {
|
||||
PasswordInput(
|
||||
onPasswordChange = onPasswordChange,
|
||||
modifier = modifier,
|
||||
password = password,
|
||||
isRequired = isRequired,
|
||||
errorMessage = errorMessage,
|
||||
contentPadding = contentPadding,
|
||||
)
|
||||
} else {
|
||||
BiometricPasswordInput(
|
||||
onPasswordChange = onPasswordChange,
|
||||
modifier = modifier,
|
||||
password = password,
|
||||
isRequired = isRequired,
|
||||
errorMessage = errorMessage,
|
||||
contentPadding = contentPadding,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
internal fun ServerSettingsPasswordInputCreatePreview() {
|
||||
PreviewWithThemes {
|
||||
ServerSettingsPasswordInput(
|
||||
mode = InteractionMode.Create,
|
||||
onPasswordChange = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
internal fun ServerSettingsPasswordInputEditPreview() {
|
||||
PreviewWithThemes {
|
||||
ServerSettingsPasswordInput(
|
||||
mode = InteractionMode.Edit,
|
||||
onPasswordChange = {},
|
||||
)
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ import androidx.compose.foundation.lazy.LazyListScope
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
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.theme.MainTheme
|
||||
|
@ -17,6 +16,7 @@ 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
|
||||
import app.k9mail.feature.account.server.settings.ui.common.ServerSettingsPasswordInput
|
||||
import app.k9mail.feature.account.server.settings.ui.common.mapper.toResourceString
|
||||
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsContract.Event
|
||||
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsContract.State
|
||||
|
@ -100,7 +100,8 @@ internal fun LazyListScope.incomingFormItems(
|
|||
|
||||
if (state.isPasswordFieldVisible) {
|
||||
item {
|
||||
PasswordInput(
|
||||
ServerSettingsPasswordInput(
|
||||
mode = mode,
|
||||
password = state.password.value,
|
||||
errorMessage = state.password.error?.toResourceString(resources),
|
||||
onPasswordChange = { onEvent(Event.PasswordChanged(it)) },
|
||||
|
|
|
@ -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.outgoing.OutgoingServerSettingsContract.Event
|
||||
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract.State
|
||||
import app.k9mail.feature.account.server.settings.ui.outgoing.content.outgoingFormItems
|
||||
|
||||
@Composable
|
||||
internal fun OutgoingServerSettingsContent(
|
||||
mode: InteractionMode,
|
||||
state: State,
|
||||
onEvent: (Event) -> Unit,
|
||||
contentPadding: PaddingValues,
|
||||
|
@ -45,6 +47,7 @@ internal fun OutgoingServerSettingsContent(
|
|||
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.default),
|
||||
) {
|
||||
outgoingFormItems(
|
||||
mode = mode,
|
||||
state = state,
|
||||
onEvent = onEvent,
|
||||
resources = resources,
|
||||
|
@ -58,8 +61,9 @@ internal fun OutgoingServerSettingsContent(
|
|||
internal fun OutgoingServerSettingsContentK9Preview() {
|
||||
K9Theme {
|
||||
OutgoingServerSettingsContent(
|
||||
onEvent = { },
|
||||
mode = InteractionMode.Create,
|
||||
state = State(),
|
||||
onEvent = { },
|
||||
contentPadding = PaddingValues(),
|
||||
)
|
||||
}
|
||||
|
@ -70,6 +74,7 @@ internal fun OutgoingServerSettingsContentK9Preview() {
|
|||
internal fun OutgoingServerSettingsContentThunderbirdPreview() {
|
||||
ThunderbirdTheme {
|
||||
OutgoingServerSettingsContent(
|
||||
mode = InteractionMode.Create,
|
||||
onEvent = { },
|
||||
state = State(),
|
||||
contentPadding = PaddingValues(),
|
||||
|
|
|
@ -64,6 +64,7 @@ fun OutgoingServerSettingsScreen(
|
|||
modifier = modifier,
|
||||
) { innerPadding ->
|
||||
OutgoingServerSettingsContent(
|
||||
mode = viewModel.mode,
|
||||
state = state.value,
|
||||
onEvent = { dispatch(it) },
|
||||
contentPadding = innerPadding,
|
||||
|
|
|
@ -7,15 +7,16 @@ import androidx.compose.foundation.lazy.LazyListScope
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
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.theme.MainTheme
|
||||
import app.k9mail.feature.account.common.domain.entity.AuthenticationType
|
||||
import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity
|
||||
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
|
||||
import app.k9mail.feature.account.server.settings.ui.common.ServerSettingsPasswordInput
|
||||
import app.k9mail.feature.account.server.settings.ui.common.mapper.toResourceString
|
||||
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract.Event
|
||||
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract.State
|
||||
|
@ -24,6 +25,7 @@ import app.k9mail.feature.account.server.settings.ui.outgoing.isUsernameFieldVis
|
|||
|
||||
@Suppress("LongMethod")
|
||||
internal fun LazyListScope.outgoingFormItems(
|
||||
mode: InteractionMode,
|
||||
state: State,
|
||||
onEvent: (Event) -> Unit,
|
||||
resources: Resources,
|
||||
|
@ -91,7 +93,8 @@ internal fun LazyListScope.outgoingFormItems(
|
|||
|
||||
if (state.isPasswordFieldVisible) {
|
||||
item {
|
||||
PasswordInput(
|
||||
ServerSettingsPasswordInput(
|
||||
mode = mode,
|
||||
password = state.password.value,
|
||||
errorMessage = state.password.error?.toResourceString(resources),
|
||||
onPasswordChange = { onEvent(Event.PasswordChanged(it)) },
|
||||
|
|
Loading…
Reference in a new issue