
Код: Выделить всё
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun OutlinedTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = LocalTextStyle.current,
placeholder: String? = null,
label: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null,
contentPadding: PaddingValues = outlinedTextFieldPadding(
start = 11.dp,
end = 11.dp,
top = 8.dp,
bottom = 8.dp
),
isError: Boolean = false,
visualTransformation: VisualTransformation = VisualTransformation.None,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions(),
singleLine: Boolean = false,
maxLength: Int = Int.MAX_VALUE,
maxLines: Int = Int.MAX_VALUE,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = RectangleShape,
colors: androidx.compose.material.TextFieldColors = TextFieldDefaults.outlinedTextFieldColors(
backgroundColor = if (enabled) Color.White else Color.Gray015,
focusedBorderColor = Color.NeonYellow10,
unfocusedBorderColor = Color.Gray014,
disabledBorderColor = Color.Transparent,
placeholderColor = Color.Gray04
)
) {
// If color is not provided via the text style, use content color as a default
val textColor = textStyle.color.takeOrElse {
colors.textColor(enabled).value
}
val mergedTextStyle = textStyle.merge(TextStyle(color = textColor))
BasicTextField(
value = value,
modifier = if (label != null) {
modifier
// Merge semantics at the beginning of the modifier chain to ensure padding is
// considered part of the text field.
.semantics(mergeDescendants = true) {}
.padding(top = 8.dp)
} else {
modifier
}
.background(colors.backgroundColor(enabled).value, shape)
.padding(vertical = contentPadding.calculateTopPadding())
.defaultMinSize(
minWidth = 120.dp,
minHeight = 24.dp
),
onValueChange = {
if (it.length
TextFieldDefaults.OutlinedTextFieldDecorationBox(
value = value,
visualTransformation = visualTransformation,
innerTextField = innerTextField,
placeholder = {
if (placeholder != null) {
Text(
text = placeholder,
fontSize = 10.sp,
lineHeight = 12.sp,
color = colors.placeholderColor(enabled).value,
)
}
},
label = label,
leadingIcon = leadingIcon,
trailingIcon = trailingIcon,
singleLine = singleLine,
enabled = enabled,
isError = isError,
interactionSource = interactionSource,
colors = colors,
contentPadding = contentPadding,
border = {
TextFieldDefaults.BorderBox(
enabled,
isError,
interactionSource,
colors,
shape
)
}
)
}
)
}
Код: Выделить всё
outlinedTextFieldPadding(
start = 11.dp,
end = 11.dp,
top = 8.dp,
bottom = 8.dp
)
Код: Выделить всё
outlinedTextFieldPadding(
start = 11.dp,
end = 11.dp,
top = 0.dp,
bottom = 0.dp
),
Как я могу решить эту проблему?
Я пробовал
Код: Выделить всё
TextFieldDefaults.OutlinedTextFieldDecorationBox()
Код: Выделить всё
Column(
verticalArrangement = Arrangement.Center
){
TextFieldDefaults.OutlinedTextFieldDecorationBox()
}