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
This commit is contained in:
Andreas 2022-08-11 15:23:56 +02:00 committed by GitHub
parent ff996d282a
commit 71fc5d6d35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -1,9 +1,11 @@
package eu.kanade.presentation.history.components package eu.kanade.presentation.history.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack 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.DeleteSweep
import androidx.compose.material.icons.outlined.Search import androidx.compose.material.icons.outlined.Search
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
@ -44,6 +46,7 @@ fun HistoryToolbar(
searchQuery = state.searchQuery!!, searchQuery = state.searchQuery!!,
onChangeSearchQuery = { state.searchQuery = it }, onChangeSearchQuery = { state.searchQuery = it },
onClickCloseSearch = { state.searchQuery = null }, onClickCloseSearch = { state.searchQuery = null },
onClickResetSearch = { state.searchQuery = "" },
incognitoMode = incognitoMode, incognitoMode = incognitoMode,
downloadedOnlyMode = downloadedOnlyMode, downloadedOnlyMode = downloadedOnlyMode,
) )
@ -79,6 +82,7 @@ fun HistorySearchToolbar(
searchQuery: String, searchQuery: String,
onChangeSearchQuery: (String) -> Unit, onChangeSearchQuery: (String) -> Unit,
onClickCloseSearch: () -> Unit, onClickCloseSearch: () -> Unit,
onClickResetSearch: () -> Unit,
incognitoMode: Boolean, incognitoMode: Boolean,
downloadedOnlyMode: Boolean, downloadedOnlyMode: Boolean,
) { ) {
@ -98,6 +102,13 @@ fun HistorySearchToolbar(
}, },
navigationIcon = Icons.Outlined.ArrowBack, navigationIcon = Icons.Outlined.ArrowBack,
navigateUp = onClickCloseSearch, navigateUp = onClickCloseSearch,
actions = {
AnimatedVisibility(visible = searchQuery.isNotEmpty()) {
IconButton(onClick = onClickResetSearch) {
Icon(Icons.Outlined.Close, contentDescription = stringResource(id = R.string.action_reset))
}
}
},
isActionMode = false, isActionMode = false,
downloadedOnlyMode = downloadedOnlyMode, downloadedOnlyMode = downloadedOnlyMode,
incognitoMode = incognitoMode, incognitoMode = incognitoMode,

View file

@ -1,10 +1,12 @@
package eu.kanade.presentation.library.components package eu.kanade.presentation.library.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.icons.Icons 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.FilterList
import androidx.compose.material.icons.outlined.FlipToBack import androidx.compose.material.icons.outlined.FlipToBack
import androidx.compose.material.icons.outlined.Refresh import androidx.compose.material.icons.outlined.Refresh
@ -64,6 +66,7 @@ fun LibraryToolbar(
downloadedOnlyMode = downloadedOnlyMode, downloadedOnlyMode = downloadedOnlyMode,
onChangeSearchQuery = { state.searchQuery = it }, onChangeSearchQuery = { state.searchQuery = it },
onClickCloseSearch = { state.searchQuery = null }, onClickCloseSearch = { state.searchQuery = null },
onClickResetSearch = { state.searchQuery = "" },
scrollBehavior = scrollBehavior, scrollBehavior = scrollBehavior,
) )
else -> LibraryRegularToolbar( else -> LibraryRegularToolbar(
@ -164,6 +167,7 @@ fun LibrarySearchToolbar(
downloadedOnlyMode: Boolean, downloadedOnlyMode: Boolean,
onChangeSearchQuery: (String) -> Unit, onChangeSearchQuery: (String) -> Unit,
onClickCloseSearch: () -> Unit, onClickCloseSearch: () -> Unit,
onClickResetSearch: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior?, scrollBehavior: TopAppBarScrollBehavior?,
) { ) {
val focusRequester = remember { FocusRequester.Default } val focusRequester = remember { FocusRequester.Default }
@ -186,6 +190,13 @@ fun LibrarySearchToolbar(
focusRequester.requestFocus() focusRequester.requestFocus()
} }
}, },
actions = {
AnimatedVisibility(visible = searchQuery.isNotEmpty()) {
IconButton(onClick = onClickResetSearch) {
Icon(Icons.Outlined.Close, contentDescription = stringResource(id = R.string.action_reset))
}
}
},
incognitoMode = incognitoMode, incognitoMode = incognitoMode,
downloadedOnlyMode = downloadedOnlyMode, downloadedOnlyMode = downloadedOnlyMode,
scrollBehavior = scrollBehavior, scrollBehavior = scrollBehavior,