1
Fork 0
mirror of https://github.com/Steffo99/twom.git synced 2024-11-24 00:54:24 +00:00

Remove FIXME by only passing actually used parameters of PasswordField to TextField

This commit is contained in:
Steffo 2024-01-24 04:41:22 +01:00
parent 8187a56e8a
commit 04a4e5bc0b
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 2 additions and 42 deletions

View file

@ -1,27 +1,18 @@
package eu.steffo.twom.composables.fields
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.RemoveRedEye
import androidx.compose.material.icons.outlined.RemoveRedEye
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldColors
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
@ -33,52 +24,22 @@ fun PasswordField(
modifier: Modifier = Modifier,
value: String = "",
onValueChange: (String) -> Unit = {},
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
prefix: @Composable (() -> Unit)? = null,
suffix: @Composable (() -> Unit)? = null,
supportingText: @Composable (() -> Unit)? = null,
isError: Boolean = false,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
singleLine: Boolean = false,
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = TextFieldDefaults.shape,
colors: TextFieldColors = TextFieldDefaults.colors()
) {
var showPassword by rememberSaveable { mutableStateOf(false) }
TextField(
// TODO: Is there a better way...?
modifier = modifier,
value = value,
onValueChange = onValueChange,
enabled = enabled,
readOnly = readOnly,
textStyle = textStyle,
label = label,
placeholder = placeholder,
leadingIcon = leadingIcon,
prefix = prefix,
suffix = suffix,
supportingText = supportingText,
isError = isError,
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
singleLine = singleLine,
maxLines = maxLines,
minLines = minLines,
interactionSource = interactionSource,
shape = shape,
colors = colors,
singleLine = true,
visualTransformation = if(showPassword) VisualTransformation.None else PasswordVisualTransformation(),
visualTransformation = if (showPassword) VisualTransformation.None else PasswordVisualTransformation(),
trailingIcon = {
IconButton(

View file

@ -196,7 +196,6 @@ fun LoginForm(
Row(Modifier.basePadding()) {
PasswordField(
modifier = Modifier.fillMaxWidth(),
singleLine = true,
value = password,
onValueChange = { password = it },
label = {