Skip to content

Commit

Permalink
feat(TransferPasswordAlertDialog): Add ImeAction configuration in Tex…
Browse files Browse the repository at this point in the history
…tField
  • Loading branch information
FabianDevel committed Nov 7, 2024
1 parent 24ec3e5 commit a0c55cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.infomaniak.swisstransfer.ui.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
Expand All @@ -30,6 +31,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
Expand Down Expand Up @@ -57,6 +59,8 @@ fun SwissTransferTextField(
maxLineNumber: Int = if (minLineNumber > 1) Int.MAX_VALUE else 1,
isPassword: Boolean = false,
keyboardType: KeyboardType = KeyboardType.Text,
imeAction: ImeAction = ImeAction.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
errorMessage: @Composable () -> String? = { null },
supportingText: String? = null,
onValueChange: ((String) -> Unit)? = null,
Expand Down Expand Up @@ -101,7 +105,9 @@ fun SwissTransferTextField(
keyboardOptions = KeyboardOptions(
keyboardType = if (isPassword) KeyboardType.Password else keyboardType,
autoCorrectEnabled = true,
imeAction = imeAction,
),
keyboardActions = keyboardActions,
isError = errorMessage() != null && text.isNotEmpty(),
supportingText = getSupportingText(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.SwissTransferAlertDialog
Expand Down Expand Up @@ -109,6 +110,7 @@ private fun ColumnScope.AnimatedPasswordInput(
label = stringResource(R.string.settingsOptionPassword),
isPassword = true,
initialValue = password.get(),
imeAction = ImeAction.Done,
errorMessage = { if (isPasswordValid()) null else stringResource(R.string.errorTransferPasswordLength) },
onValueChange = { password.set(it) },
)
Expand Down

0 comments on commit a0c55cb

Please sign in to comment.