diff --git a/app/src/main/java/com/orange/ods/app/ui/components/textfields/ComponentTextField.kt b/app/src/main/java/com/orange/ods/app/ui/components/textfields/ComponentTextField.kt index 807cacc2c..495d4de41 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/textfields/ComponentTextField.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/textfields/ComponentTextField.kt @@ -111,6 +111,10 @@ private fun TextFieldTextCustomization(textFieldCustomizationState: TextFieldCus @Composable private fun TextFieldPasswordCustomization(textFieldCustomizationState: TextFieldCustomizationState) { with(textFieldCustomizationState) { + OdsListItem( + text = stringResource(id = R.string.component_element_leading_icon), + trailing = OdsListItemTrailingSwitch(leadingIcon.value, { leadingIcon.value = it }) + ) DisplayTypeCustomization(displayType) OdsListItem( text = stringResource(id = R.string.component_text_field_visualisation_icon), @@ -244,4 +248,4 @@ private enum class CustomizationTab(@StringRes val titleRes: Int) { Keyboard -> KeyboardCustomizationContent(textFieldCustomizationState = textFieldCustomizationState) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/orange/ods/app/ui/components/textfields/TextFieldPassword.kt b/app/src/main/java/com/orange/ods/app/ui/components/textfields/TextFieldPassword.kt index 0ef898059..1f8e76d1c 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/textfields/TextFieldPassword.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/textfields/TextFieldPassword.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import com.orange.ods.app.R import com.orange.ods.compose.OdsComposable @@ -28,11 +29,13 @@ fun TextFieldPassword(customizationState: TextFieldCustomizationState) { val errorMessage = stringResource(id = R.string.component_text_field_error_message) with(customizationState) { + val leadingIcon = if (hasLeadingIcon) painterResource(id = R.drawable.ic_lock) else null Column { OdsPasswordTextField( modifier = Modifier .fillMaxWidth() .padding(top = dimensionResource(id = com.orange.ods.R.dimen.spacing_s)), + leadingIcon = leadingIcon, enabled = isEnabled, isError = isError, errorMessage = if (isError) errorMessage else null, @@ -59,4 +62,4 @@ fun TextFieldPassword(customizationState: TextFieldCustomizationState) { ) } } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/ic_lock.xml b/app/src/main/res/drawable/ic_lock.xml new file mode 100644 index 000000000..590a75af7 --- /dev/null +++ b/app/src/main/res/drawable/ic_lock.xml @@ -0,0 +1,15 @@ + + + + diff --git a/lib/src/main/java/com/orange/ods/compose/component/textfield/password/OdsPasswordTextField.kt b/lib/src/main/java/com/orange/ods/compose/component/textfield/password/OdsPasswordTextField.kt index cd583bab6..40eeb1e56 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/textfield/password/OdsPasswordTextField.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/textfield/password/OdsPasswordTextField.kt @@ -22,6 +22,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction @@ -58,6 +59,10 @@ import com.orange.ods.compose.component.utilities.UiModePreviews * [Typography.subtitle1] when the text field is not in focus * @param placeholder the optional placeholder to be displayed when the text field is in focus and * the input text is empty. The default text style for internal [Text] is [Typography.subtitle1] + * @param leadingIcon the optional leading icon painter to be displayed at the beginning of the text field + * container + * @param leadingIconContentDescription the optional content description for the leading icon. + * @param onLeadingIconClick the optional action executed on leading icon click. * @param visualisationIcon If `true`, an eye icon will be display to allow showing/hiding password. * @param isError indicates if the text field's current value is in error state. If set to * true, the label, bottom indicator and trailing icon by default will be displayed in error color @@ -79,6 +84,9 @@ fun OdsPasswordTextField( readOnly: Boolean = false, label: String? = null, placeholder: String? = null, + leadingIcon: Painter? = null, + leadingIconContentDescription: String? = null, + onLeadingIconClick: (() -> Unit)? = null, visualisationIcon: Boolean = true, isError: Boolean = false, errorMessage: String? = null, @@ -100,6 +108,9 @@ fun OdsPasswordTextField( readOnly = readOnly, label = label, placeholder = placeholder, + leadingIcon = leadingIcon, + leadingIconContentDescription = leadingIconContentDescription, + onLeadingIconClick = onLeadingIconClick, trailing = if (visualisationIcon) { { OdsPasswordVisualisationIcon(odsPasswordTextFieldState) } } else null, @@ -136,6 +147,7 @@ private fun PreviewOdsPasswordTextField(@PreviewParameter(OdsPasswordTextFieldPr OdsPasswordTextField( value = value, onValueChange = { value = it }, + leadingIcon = painterResource(id = android.R.drawable.ic_dialog_info), placeholder = "Placeholder", isError = hasErrorMessage, errorMessage = if (hasErrorMessage) "Error message" else null