Clear search text when navigating back

This commit is contained in:
Jackson Harper 2023-04-19 12:25:00 +08:00
parent 1610ae4930
commit f3019b0a6e
2 changed files with 8 additions and 19 deletions

View file

@ -73,7 +73,7 @@ fun SearchField(
val keyboardController = LocalSoftwareKeyboardController.current
val focusRequester = remember { FocusRequester() }
TextField(
TextField(
modifier = Modifier
.fillMaxWidth()
// .padding(vertical = 2.dp)
@ -86,16 +86,18 @@ fun SearchField(
placeholder = {
Text(text = "Search")
},
leadingIcon = {
IconButton(
onClick = { navController.popBackStack() }
) {
leadingIcon = {
IconButton(
onClick = {
onSearchTextChanged("")
navController.popBackStack()
}) {
Icon(
imageVector = androidx.compose.material.icons.Icons.Filled.ArrowBack,
contentDescription = "Back"
)
}
},
},
trailingIcon = {
AnimatedVisibility(
visible = showClearButton,

View file

@ -45,19 +45,6 @@ fun SearchView(
topBar = {
TopAppBar(
title = { Text("") },
// SearchField(searchText) { libraryViewModel.updateSearchText(it) }
// },
// navigationIcon = {
// IconButton(
// modifier = Modifier.background(color = Color.Red),
// onClick = { navController.popBackStack() }
// ) {
// Icon(
// imageVector = androidx.compose.material.icons.Icons.Filled.ArrowBack,
// contentDescription = "Back"
// )
// },
actions = {
Row {
SearchField(