From 71fc5d6d35b0b10917f3db80b236b35fbbdaab3a Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 11 Aug 2022 15:23:56 +0200 Subject: [PATCH] Add back reset action to the Library and History Search toolbars (#7722) * Add back reset action to the Library and History Search toolbars * Localize the descriptions --- .../presentation/history/components/HistoryToolbar.kt | 11 +++++++++++ .../presentation/library/components/LibraryToolbar.kt | 11 +++++++++++ 2 files changed, 22 insertions(+) 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 f615d9c607..88adb52daf 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 a8a2d795e0..0c7c7f1ceb 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,