From 44366ac0580d3e51c03cbed8530e48ebe37f2e1f Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 27 Nov 2022 15:16:08 -0500 Subject: [PATCH] Minor global search UI tweaks --- .../presentation/browse/GlobalSearchScreen.kt | 5 +++-- .../presentation/browse/MigrateSearchScreen.kt | 3 ++- .../browse/components/GlobalSearchResultItems.kt | 16 +++++++++++++--- .../browse/components/GlobalSearchToolbar.kt | 3 +++ .../migration/search/MigrateSearchScreen.kt | 8 ++++---- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt index 014039448..76444f4a8 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt @@ -35,7 +35,7 @@ fun GlobalSearchScreen( onLongClickItem: (Manga) -> Unit, ) { Scaffold( - topBar = { + topBar = { scrollBehavior -> GlobalSearchToolbar( searchQuery = state.searchQuery, progress = state.progress, @@ -43,6 +43,7 @@ fun GlobalSearchScreen( navigateUp = navigateUp, onChangeSearchQuery = onChangeSearchQuery, onSearch = onSearch, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> @@ -86,7 +87,7 @@ fun GlobalSearchContent( is GlobalSearchItemResult.Success -> { if (result.isEmpty) { Text( - text = stringResource(id = R.string.no_results_found), + text = stringResource(R.string.no_results_found), modifier = Modifier .padding( horizontal = MaterialTheme.padding.medium, diff --git a/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt index 436c9bc2b..b80cfbfe4 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt @@ -29,7 +29,7 @@ fun MigrateSearchScreen( onLongClickItem: (Manga) -> Unit, ) { Scaffold( - topBar = { + topBar = { scrollBehavior -> GlobalSearchToolbar( searchQuery = state.searchQuery, progress = state.progress, @@ -37,6 +37,7 @@ fun MigrateSearchScreen( navigateUp = navigateUp, onChangeSearchQuery = onChangeSearchQuery, onSearch = onSearch, + scrollBehavior = scrollBehavior, ) }, ) { paddingValues -> diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchResultItems.kt b/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchResultItems.kt index ba4ec27b7..f1b3c9a53 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchResultItems.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchResultItems.kt @@ -5,7 +5,9 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons @@ -20,6 +22,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import eu.kanade.presentation.util.padding import eu.kanade.tachiyomi.R @@ -61,7 +64,7 @@ fun GlobalSearchResultItem( @Composable fun GlobalSearchEmptyResultItem() { Text( - text = stringResource(id = R.string.no_results_found), + text = stringResource(R.string.no_results_found), modifier = Modifier .padding( horizontal = MaterialTheme.padding.medium, @@ -90,12 +93,19 @@ fun GlobalSearchLoadingResultItem() { fun GlobalSearchErrorResultItem(message: String?) { Column( modifier = Modifier - .padding(vertical = MaterialTheme.padding.medium) + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small, + ) .fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center, ) { Icon(imageVector = Icons.Outlined.Error, contentDescription = null) - Text(text = message ?: stringResource(id = R.string.unknown_error)) + Spacer(Modifier.height(4.dp)) + Text( + text = message ?: stringResource(R.string.unknown_error), + textAlign = TextAlign.Center, + ) } } diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchToolbar.kt index c05a1c9e4..2924a8633 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/GlobalSearchToolbar.kt @@ -3,6 +3,7 @@ package eu.kanade.presentation.browse.components import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.LinearProgressIndicator +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -16,6 +17,7 @@ fun GlobalSearchToolbar( navigateUp: () -> Unit, onChangeSearchQuery: (String?) -> Unit, onSearch: (String) -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { Box { SearchToolbar( @@ -23,6 +25,7 @@ fun GlobalSearchToolbar( onChangeSearchQuery = onChangeSearchQuery, onSearch = onSearch, navigateUp = navigateUp, + scrollBehavior = scrollBehavior, ) if (progress in 1 until total) { LinearProgressIndicator( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt index 7b57e423b..108b969f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreen.kt @@ -132,7 +132,7 @@ fun MigrateDialog( AlertDialog( onDismissRequest = onDismissRequest, title = { - Text(text = stringResource(id = R.string.migration_dialog_what_to_include)) + Text(text = stringResource(R.string.migration_dialog_what_to_include)) }, text = { Column { @@ -155,7 +155,7 @@ fun MigrateDialog( onDismissRequest() }, ) { - Text(text = stringResource(id = R.string.action_show_manga)) + Text(text = stringResource(R.string.action_show_manga)) } TextButton(onClick = { scope.launchIO { @@ -165,7 +165,7 @@ fun MigrateDialog( } } },) { - Text(text = stringResource(id = R.string.copy)) + Text(text = stringResource(R.string.copy)) } TextButton(onClick = { scope.launchIO { @@ -179,7 +179,7 @@ fun MigrateDialog( } } },) { - Text(text = stringResource(id = R.string.migrate)) + Text(text = stringResource(R.string.migrate)) } } },