From 22e83f408bc6c19457cc8a03ed7f02d69e9308c7 Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 10 Aug 2022 21:56:52 +0200 Subject: [PATCH] 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 --- .../presentation/library/components/LazyLibraryGrid.kt | 5 ++++- .../library/components/LibraryComfortableGrid.kt | 6 +++--- .../presentation/library/components/LibraryCompactGrid.kt | 6 +++--- .../presentation/library/components/LibraryCoverOnlyGrid.kt | 6 +++--- .../kanade/presentation/library/components/LibraryList.kt | 6 +++--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt index 41b09fd6bd..98bc3a9ede 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt @@ -42,7 +42,10 @@ fun LazyGridScope.globalSearchItem( onGlobalSearchClicked: () -> Unit, ) { if (searchQuery.isNullOrEmpty().not()) { - item(span = { GridItemSpan(maxLineSpan) }) { + item( + span = { GridItemSpan(maxLineSpan) }, + contentType = { "library_global_search_item" }, + ) { TextButton(onClick = onGlobalSearchClicked) { Text( text = stringResource(R.string.action_global_search_query, searchQuery!!), diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt index 23e089a838..39bb4be4b1 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt @@ -2,6 +2,7 @@ package eu.kanade.presentation.library.components import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.items import androidx.compose.material3.MaterialTheme @@ -25,15 +26,14 @@ fun LibraryComfortableGrid( onGlobalSearchClicked: () -> Unit, ) { LazyLibraryGrid( + modifier = Modifier.fillMaxSize(), columns = columns, ) { globalSearchItem(searchQuery, onGlobalSearchClicked) items( items = items, - key = { - it.manga.id!! - }, + contentType = { "library_comfortable_grid_item" }, ) { libraryItem -> LibraryComfortableGridItem( libraryItem, diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt index 8d588d7303..e8a21b7c5e 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.items @@ -33,15 +34,14 @@ fun LibraryCompactGrid( onGlobalSearchClicked: () -> Unit, ) { LazyLibraryGrid( + modifier = Modifier.fillMaxSize(), columns = columns, ) { globalSearchItem(searchQuery, onGlobalSearchClicked) items( items = items, - key = { - it.manga.id!! - }, + contentType = { "library_compact_grid_item" }, ) { libraryItem -> LibraryCompactGridItem( item = libraryItem, diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryCoverOnlyGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryCoverOnlyGrid.kt index 41511c9ef4..fd1249f12b 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryCoverOnlyGrid.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryCoverOnlyGrid.kt @@ -1,6 +1,7 @@ package eu.kanade.presentation.library.components import androidx.compose.foundation.combinedClickable +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.lazy.grid.items import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -18,15 +19,14 @@ fun LibraryCoverOnlyGrid( onGlobalSearchClicked: () -> Unit, ) { LazyLibraryGrid( + modifier = Modifier.fillMaxSize(), columns = columns, ) { globalSearchItem(searchQuery, onGlobalSearchClicked) items( items = items, - key = { - it.manga.id!! - }, + contentType = { "library_only_cover_grid_item" }, ) { libraryItem -> LibraryCoverOnlyGridItem( item = libraryItem, diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt index 3aba1bb62d..8f35b43445 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt @@ -3,6 +3,7 @@ package eu.kanade.presentation.library.components import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.items @@ -37,6 +38,7 @@ fun LibraryList( onGlobalSearchClicked: () -> Unit, ) { FastScrollLazyColumn( + modifier = Modifier.fillMaxSize(), contentPadding = bottomNavPaddingValues, ) { item { @@ -52,9 +54,7 @@ fun LibraryList( items( items = items, - key = { - it.manga.id!! - }, + contentType = { "library_list_item" }, ) { libraryItem -> LibraryListItem( item = libraryItem,