Tweak Library screen (#7718)

* Allow to refresh when there is white space

fixes #7701

* Don't use key on library screen as it retains scroll position on first item

fixes #7631
This commit is contained in:
Andreas 2022-08-10 21:56:52 +02:00 committed by GitHub
parent ec96a81735
commit 22e83f408b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 13 deletions

View File

@ -42,7 +42,10 @@ fun LazyGridScope.globalSearchItem(
onGlobalSearchClicked: () -> Unit, onGlobalSearchClicked: () -> Unit,
) { ) {
if (searchQuery.isNullOrEmpty().not()) { if (searchQuery.isNullOrEmpty().not()) {
item(span = { GridItemSpan(maxLineSpan) }) { item(
span = { GridItemSpan(maxLineSpan) },
contentType = { "library_global_search_item" },
) {
TextButton(onClick = onGlobalSearchClicked) { TextButton(onClick = onGlobalSearchClicked) {
Text( Text(
text = stringResource(R.string.action_global_search_query, searchQuery!!), text = stringResource(R.string.action_global_search_query, searchQuery!!),

View File

@ -2,6 +2,7 @@ package eu.kanade.presentation.library.components
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
@ -25,15 +26,14 @@ fun LibraryComfortableGrid(
onGlobalSearchClicked: () -> Unit, onGlobalSearchClicked: () -> Unit,
) { ) {
LazyLibraryGrid( LazyLibraryGrid(
modifier = Modifier.fillMaxSize(),
columns = columns, columns = columns,
) { ) {
globalSearchItem(searchQuery, onGlobalSearchClicked) globalSearchItem(searchQuery, onGlobalSearchClicked)
items( items(
items = items, items = items,
key = { contentType = { "library_comfortable_grid_item" },
it.manga.id!!
},
) { libraryItem -> ) { libraryItem ->
LibraryComfortableGridItem( LibraryComfortableGridItem(
libraryItem, libraryItem,

View File

@ -4,6 +4,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.items
@ -33,15 +34,14 @@ fun LibraryCompactGrid(
onGlobalSearchClicked: () -> Unit, onGlobalSearchClicked: () -> Unit,
) { ) {
LazyLibraryGrid( LazyLibraryGrid(
modifier = Modifier.fillMaxSize(),
columns = columns, columns = columns,
) { ) {
globalSearchItem(searchQuery, onGlobalSearchClicked) globalSearchItem(searchQuery, onGlobalSearchClicked)
items( items(
items = items, items = items,
key = { contentType = { "library_compact_grid_item" },
it.manga.id!!
},
) { libraryItem -> ) { libraryItem ->
LibraryCompactGridItem( LibraryCompactGridItem(
item = libraryItem, item = libraryItem,

View File

@ -1,6 +1,7 @@
package eu.kanade.presentation.library.components package eu.kanade.presentation.library.components
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.items
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -18,15 +19,14 @@ fun LibraryCoverOnlyGrid(
onGlobalSearchClicked: () -> Unit, onGlobalSearchClicked: () -> Unit,
) { ) {
LazyLibraryGrid( LazyLibraryGrid(
modifier = Modifier.fillMaxSize(),
columns = columns, columns = columns,
) { ) {
globalSearchItem(searchQuery, onGlobalSearchClicked) globalSearchItem(searchQuery, onGlobalSearchClicked)
items( items(
items = items, items = items,
key = { contentType = { "library_only_cover_grid_item" },
it.manga.id!!
},
) { libraryItem -> ) { libraryItem ->
LibraryCoverOnlyGridItem( LibraryCoverOnlyGridItem(
item = libraryItem, item = libraryItem,

View File

@ -3,6 +3,7 @@ package eu.kanade.presentation.library.components
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
@ -37,6 +38,7 @@ fun LibraryList(
onGlobalSearchClicked: () -> Unit, onGlobalSearchClicked: () -> Unit,
) { ) {
FastScrollLazyColumn( FastScrollLazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = bottomNavPaddingValues, contentPadding = bottomNavPaddingValues,
) { ) {
item { item {
@ -52,9 +54,7 @@ fun LibraryList(
items( items(
items = items, items = items,
key = { contentType = { "library_list_item" },
it.manga.id!!
},
) { libraryItem -> ) { libraryItem ->
LibraryListItem( LibraryListItem(
item = libraryItem, item = libraryItem,