Skip to content

[feature] Add KeyboardOptions, actions, and disable textField feature #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.OutlinedTextField
Expand Down Expand Up @@ -75,7 +76,10 @@ fun DayoTextField(
errorMessage: String = "",
textAlign: TextAlign = TextAlign.Left,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
onTrailingIconClick: (() -> Unit) = { }
onTrailingIconClick: (() -> Unit) = { },
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
isEnabled: Boolean = true,
) {
Column(
modifier = modifier,
Expand All @@ -102,7 +106,10 @@ fun DayoTextField(
color = Dark,
fontStyle = DayoTheme.typography.b4.fontStyle
),
enabled = isEnabled,
interactionSource = interactionSource,
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
decorationBox = @Composable { innerTextField ->
TextFieldDefaults.DecorationBox(
value = value,
Expand All @@ -118,7 +125,7 @@ fun DayoTextField(
},
singleLine = true,
isError = isError ?: false,
enabled = true,
enabled = isEnabled,
interactionSource = interactionSource,
contentPadding = PaddingValues(
start = contentPadding.calculateStartPadding(LayoutDirection.Ltr),
Expand Down Expand Up @@ -190,7 +197,10 @@ fun DayoPasswordTextField(
errorMessage: String = "",
textAlign: TextAlign = TextAlign.Left,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
onErrorIconClick: (() -> Unit) = { }
onErrorIconClick: (() -> Unit) = { },
keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
keyboardActions: KeyboardActions = KeyboardActions.Default,
isEnabled: Boolean = true,
) {
Column(
modifier = modifier,
Expand Down Expand Up @@ -219,8 +229,10 @@ fun DayoPasswordTextField(
color = Dark,
fontStyle = DayoTheme.typography.b4.fontStyle
),
enabled = isEnabled,
visualTransformation = if (passwordHidden) PasswordVisualTransformation(mask = '●') else VisualTransformation.None,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
interactionSource = interactionSource,
decorationBox = @Composable { innerTextField ->
TextFieldDefaults.DecorationBox(
Expand All @@ -237,7 +249,7 @@ fun DayoPasswordTextField(
},
singleLine = true,
isError = isError ?: false,
enabled = true,
enabled = isEnabled,
interactionSource = interactionSource,
contentPadding = PaddingValues(
start = contentPadding.calculateStartPadding(LayoutDirection.Ltr),
Expand Down Expand Up @@ -313,6 +325,9 @@ fun DayoTimerTextField(
timeOutErrorMessage: String = stringResource(id = R.string.email_address_certificate_alert_message_time_fail),
textAlign: TextAlign = TextAlign.Left,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
keyboardActions: KeyboardActions = KeyboardActions.Default,
isEnabled: Boolean = true,
) {
var timeLeft by rememberSaveable { mutableIntStateOf(seconds) }

Expand Down Expand Up @@ -348,6 +363,9 @@ fun DayoTimerTextField(
color = Dark,
fontStyle = DayoTheme.typography.b4.fontStyle
),
enabled = isEnabled,
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
interactionSource = interactionSource,
decorationBox = @Composable { innerTextField ->
TextFieldDefaults.DecorationBox(
Expand All @@ -364,7 +382,7 @@ fun DayoTimerTextField(
},
singleLine = true,
isError = isError || timeLeft == 0,
enabled = true,
enabled = isEnabled,
interactionSource = interactionSource,
contentPadding = PaddingValues(
start = contentPadding.calculateStartPadding(LayoutDirection.Ltr),
Expand Down
Loading