diff --git a/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt b/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt index f615d9c60..88adb52da 100644 --- a/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt @@ -1,9 +1,11 @@ package eu.kanade.presentation.history.components +import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.text.BasicTextField import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.ArrowBack +import androidx.compose.material.icons.outlined.Close import androidx.compose.material.icons.outlined.DeleteSweep import androidx.compose.material.icons.outlined.Search import androidx.compose.material3.Icon @@ -44,6 +46,7 @@ fun HistoryToolbar( searchQuery = state.searchQuery!!, onChangeSearchQuery = { state.searchQuery = it }, onClickCloseSearch = { state.searchQuery = null }, + onClickResetSearch = { state.searchQuery = "" }, incognitoMode = incognitoMode, downloadedOnlyMode = downloadedOnlyMode, ) @@ -79,6 +82,7 @@ fun HistorySearchToolbar( searchQuery: String, onChangeSearchQuery: (String) -> Unit, onClickCloseSearch: () -> Unit, + onClickResetSearch: () -> Unit, incognitoMode: Boolean, downloadedOnlyMode: Boolean, ) { @@ -98,6 +102,13 @@ fun HistorySearchToolbar( }, navigationIcon = Icons.Outlined.ArrowBack, navigateUp = onClickCloseSearch, + actions = { + AnimatedVisibility(visible = searchQuery.isNotEmpty()) { + IconButton(onClick = onClickResetSearch) { + Icon(Icons.Outlined.Close, contentDescription = stringResource(id = R.string.action_reset)) + } + } + }, isActionMode = false, downloadedOnlyMode = downloadedOnlyMode, incognitoMode = incognitoMode, diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt index a8a2d795e..0c7c7f1ce 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryToolbar.kt @@ -1,10 +1,12 @@ package eu.kanade.presentation.library.components +import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.text.BasicTextField import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Close import androidx.compose.material.icons.outlined.FilterList import androidx.compose.material.icons.outlined.FlipToBack import androidx.compose.material.icons.outlined.Refresh @@ -64,6 +66,7 @@ fun LibraryToolbar( downloadedOnlyMode = downloadedOnlyMode, onChangeSearchQuery = { state.searchQuery = it }, onClickCloseSearch = { state.searchQuery = null }, + onClickResetSearch = { state.searchQuery = "" }, scrollBehavior = scrollBehavior, ) else -> LibraryRegularToolbar( @@ -164,6 +167,7 @@ fun LibrarySearchToolbar( downloadedOnlyMode: Boolean, onChangeSearchQuery: (String) -> Unit, onClickCloseSearch: () -> Unit, + onClickResetSearch: () -> Unit, scrollBehavior: TopAppBarScrollBehavior?, ) { val focusRequester = remember { FocusRequester.Default } @@ -186,6 +190,13 @@ fun LibrarySearchToolbar( focusRequester.requestFocus() } }, + actions = { + AnimatedVisibility(visible = searchQuery.isNotEmpty()) { + IconButton(onClick = onClickResetSearch) { + Icon(Icons.Outlined.Close, contentDescription = stringResource(id = R.string.action_reset)) + } + } + }, incognitoMode = incognitoMode, downloadedOnlyMode = downloadedOnlyMode, scrollBehavior = scrollBehavior,