Added button to clear search in side panel

This commit is contained in:
Abdelilah El Aissaoui 2023-11-04 00:35:58 +01:00
parent 456978eefc
commit 4323924ed6
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -135,7 +135,7 @@ fun FilterTextField(value: String, onValueChange: (String) -> Unit, modifier: Mo
fontSize = MaterialTheme.typography.body2.fontSize, fontSize = MaterialTheme.typography.body2.fontSize,
color = MaterialTheme.colors.onBackground, color = MaterialTheme.colors.onBackground,
), ),
maxLines = 1, singleLine = true,
leadingIcon = { leadingIcon = {
Icon( Icon(
painterResource(AppIcons.SEARCH), painterResource(AppIcons.SEARCH),
@ -143,6 +143,22 @@ fun FilterTextField(value: String, onValueChange: (String) -> Unit, modifier: Mo
modifier = Modifier.size(16.dp), modifier = Modifier.size(16.dp),
tint = if (value.isEmpty()) MaterialTheme.colors.onBackgroundSecondary else MaterialTheme.colors.onBackground tint = if (value.isEmpty()) MaterialTheme.colors.onBackgroundSecondary else MaterialTheme.colors.onBackground
) )
},
trailingIcon = {
if (value.isNotEmpty()) {
IconButton(
onClick = { onValueChange("") },
modifier = Modifier
.size(16.dp)
.handOnHover(),
) {
Icon(
painterResource(AppIcons.CLOSE),
contentDescription = null,
tint = if (value.isEmpty()) MaterialTheme.colors.onBackgroundSecondary else MaterialTheme.colors.onBackground
)
}
}
} }
) )
} }