Ink
08/02/2021, 2:42 PMTextField(
value = titleState.value,
onValueChange = { titleState.value = it },
colors = TextFieldDefaults.textFieldColors(
textColor = MaterialTheme.colors.primary,
disabledTextColor = Color.Transparent,
backgroundColor = Color.Transparent,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
)
)
The problem is when I want to put down text there is a text instead of hint and I have to delete text before typing the proper wordLandry Norris
08/02/2021, 2:48 PM{ Text("Searching for...") }
Landry Norris
08/02/2021, 2:53 PMInk
08/02/2021, 2:56 PMZach Klippenstein (he/him) [MOD]
08/02/2021, 3:20 PMplaceholder
slot do what you want? I thought that was for hintInk
08/02/2021, 3:22 PMLandry Norris
08/02/2021, 3:22 PMTin Tran
08/02/2021, 3:34 PMZach Klippenstein (he/him) [MOD]
08/02/2021, 3:37 PMlabel
to empty if the field is focused or has text. I think that would be janky on at least one of the transition animations though.Landry Norris
08/02/2021, 3:38 PMmuthuraj
08/02/2021, 3:57 PMInk
08/02/2021, 9:07 PMmuthuraj
08/03/2021, 5:36 AM@Composable
private fun SearchBox(
value: String,
onValueChange: (String) -> Unit
) {
Box(
modifier = Modifier
.padding(16.dp)
.background(
shape = RoundedCornerShape(corner = CornerSize(4.dp)),
color = Color(0xFFF1F0F1)
)
) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) {
Row(modifier = Modifier.padding(12.dp)) {
Icon(
modifier = Modifier
.height(20.dp)
.align(Alignment.CenterVertically),
painter = rememberVectorPainter(image = Icons.Outlined.Search),
contentDescription = null
)
Box(
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(horizontal = 10.dp)
.weight(1f)
) {
if (value.isEmpty()) {
Text(
text = "Search",
style = MaterialTheme.typography.subtitle1
)
}
BasicTextField(
modifier = Modifier
.fillMaxWidth(),
value = value,
onValueChange = onValueChange,
singleLine = true,
textStyle = MaterialTheme.typography.subtitle1
)
}
if (value.isNotBlank()) {
Icon(
modifier = Modifier
.height(20.dp)
.align(Alignment.CenterVertically)
.clickable { onValueChange("") },
painter = rememberVectorPainter(image = Icons.Outlined.Close),
contentDescription = null
)
}
}
}
}
}