Move library page EmptyScreens into list/grids
It does look awkward due to the lack of filled height within those list/grids though. Fixes #8720 Fixes #8721
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.kanade.presentation.library.components
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -22,6 +23,7 @@ fun LibraryComfortableGrid(
|
||||
onClickContinueReading: ((LibraryManga) -> Unit)?,
|
||||
searchQuery: String?,
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
hasActiveFilters: Boolean,
|
||||
) {
|
||||
LazyLibraryGrid(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
@@ -30,39 +32,48 @@ fun LibraryComfortableGrid(
|
||||
) {
|
||||
globalSearchItem(searchQuery, onGlobalSearchClicked)
|
||||
|
||||
items(
|
||||
items = items,
|
||||
contentType = { "library_comfortable_grid_item" },
|
||||
) { libraryItem ->
|
||||
val manga = libraryItem.libraryManga.manga
|
||||
MangaComfortableGridItem(
|
||||
isSelected = selection.fastAny { it.id == libraryItem.libraryManga.id },
|
||||
title = manga.title,
|
||||
coverData = MangaCover(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverBadgeStart = {
|
||||
DownloadsBadge(count = libraryItem.downloadCount.toInt())
|
||||
UnreadBadge(count = libraryItem.unreadCount.toInt())
|
||||
},
|
||||
coverBadgeEnd = {
|
||||
LanguageBadge(
|
||||
isLocal = libraryItem.isLocal,
|
||||
sourceLanguage = libraryItem.sourceLanguage,
|
||||
)
|
||||
},
|
||||
onLongClick = { onLongClick(libraryItem.libraryManga) },
|
||||
onClick = { onClick(libraryItem.libraryManga) },
|
||||
onClickContinueReading = if (onClickContinueReading != null) {
|
||||
{ onClickContinueReading(libraryItem.libraryManga) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
if (items.isEmpty()) {
|
||||
item(
|
||||
span = { GridItemSpan(maxLineSpan) },
|
||||
contentType = "library_comfortable_grid_empty",
|
||||
) {
|
||||
LibraryPagerEmptyScreen(searchQuery, hasActiveFilters, contentPadding)
|
||||
}
|
||||
} else {
|
||||
items(
|
||||
items = items,
|
||||
contentType = { "library_comfortable_grid_item" },
|
||||
) { libraryItem ->
|
||||
val manga = libraryItem.libraryManga.manga
|
||||
MangaComfortableGridItem(
|
||||
isSelected = selection.fastAny { it.id == libraryItem.libraryManga.id },
|
||||
title = manga.title,
|
||||
coverData = MangaCover(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverBadgeStart = {
|
||||
DownloadsBadge(count = libraryItem.downloadCount.toInt())
|
||||
UnreadBadge(count = libraryItem.unreadCount.toInt())
|
||||
},
|
||||
coverBadgeEnd = {
|
||||
LanguageBadge(
|
||||
isLocal = libraryItem.isLocal,
|
||||
sourceLanguage = libraryItem.sourceLanguage,
|
||||
)
|
||||
},
|
||||
onLongClick = { onLongClick(libraryItem.libraryManga) },
|
||||
onClick = { onClick(libraryItem.libraryManga) },
|
||||
onClickContinueReading = if (onClickContinueReading != null) {
|
||||
{ onClickContinueReading(libraryItem.libraryManga) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.kanade.presentation.library.components
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -23,6 +24,7 @@ fun LibraryCompactGrid(
|
||||
onClickContinueReading: ((LibraryManga) -> Unit)?,
|
||||
searchQuery: String?,
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
hasActiveFilters: Boolean,
|
||||
) {
|
||||
LazyLibraryGrid(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
@@ -31,39 +33,48 @@ fun LibraryCompactGrid(
|
||||
) {
|
||||
globalSearchItem(searchQuery, onGlobalSearchClicked)
|
||||
|
||||
items(
|
||||
items = items,
|
||||
contentType = { "library_compact_grid_item" },
|
||||
) { libraryItem ->
|
||||
val manga = libraryItem.libraryManga.manga
|
||||
MangaCompactGridItem(
|
||||
isSelected = selection.fastAny { it.id == libraryItem.libraryManga.id },
|
||||
title = manga.title.takeIf { showTitle },
|
||||
coverData = MangaCover(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverBadgeStart = {
|
||||
DownloadsBadge(count = libraryItem.downloadCount.toInt())
|
||||
UnreadBadge(count = libraryItem.unreadCount.toInt())
|
||||
},
|
||||
coverBadgeEnd = {
|
||||
LanguageBadge(
|
||||
isLocal = libraryItem.isLocal,
|
||||
sourceLanguage = libraryItem.sourceLanguage,
|
||||
)
|
||||
},
|
||||
onLongClick = { onLongClick(libraryItem.libraryManga) },
|
||||
onClick = { onClick(libraryItem.libraryManga) },
|
||||
onClickContinueReading = if (onClickContinueReading != null) {
|
||||
{ onClickContinueReading(libraryItem.libraryManga) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
if (items.isEmpty()) {
|
||||
item(
|
||||
span = { GridItemSpan(maxLineSpan) },
|
||||
contentType = "library_compact_grid_empty",
|
||||
) {
|
||||
LibraryPagerEmptyScreen(searchQuery, hasActiveFilters, contentPadding)
|
||||
}
|
||||
} else {
|
||||
items(
|
||||
items = items,
|
||||
contentType = { "library_compact_grid_item" },
|
||||
) { libraryItem ->
|
||||
val manga = libraryItem.libraryManga.manga
|
||||
MangaCompactGridItem(
|
||||
isSelected = selection.fastAny { it.id == libraryItem.libraryManga.id },
|
||||
title = manga.title.takeIf { showTitle },
|
||||
coverData = MangaCover(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
coverBadgeStart = {
|
||||
DownloadsBadge(count = libraryItem.downloadCount.toInt())
|
||||
UnreadBadge(count = libraryItem.unreadCount.toInt())
|
||||
},
|
||||
coverBadgeEnd = {
|
||||
LanguageBadge(
|
||||
isLocal = libraryItem.isLocal,
|
||||
sourceLanguage = libraryItem.sourceLanguage,
|
||||
)
|
||||
},
|
||||
onLongClick = { onLongClick(libraryItem.libraryManga) },
|
||||
onClick = { onClick(libraryItem.libraryManga) },
|
||||
onClickContinueReading = if (onClickContinueReading != null) {
|
||||
{ onClickContinueReading(libraryItem.libraryManga) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ fun LibraryList(
|
||||
onClickContinueReading: ((LibraryManga) -> Unit)?,
|
||||
searchQuery: String?,
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
hasActiveFilters: Boolean,
|
||||
) {
|
||||
FastScrollLazyColumn(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
@@ -49,37 +50,45 @@ fun LibraryList(
|
||||
}
|
||||
}
|
||||
|
||||
items(
|
||||
items = items,
|
||||
contentType = { "library_list_item" },
|
||||
) { libraryItem ->
|
||||
val manga = libraryItem.libraryManga.manga
|
||||
MangaListItem(
|
||||
isSelected = selection.fastAny { it.id == libraryItem.libraryManga.id },
|
||||
title = manga.title,
|
||||
coverData = MangaCover(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
badge = {
|
||||
DownloadsBadge(count = libraryItem.downloadCount.toInt())
|
||||
UnreadBadge(count = libraryItem.unreadCount.toInt())
|
||||
LanguageBadge(
|
||||
isLocal = libraryItem.isLocal,
|
||||
sourceLanguage = libraryItem.sourceLanguage,
|
||||
)
|
||||
},
|
||||
onLongClick = { onLongClick(libraryItem.libraryManga) },
|
||||
onClick = { onClick(libraryItem.libraryManga) },
|
||||
onClickContinueReading = if (onClickContinueReading != null) {
|
||||
{ onClickContinueReading(libraryItem.libraryManga) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
if (items.isEmpty()) {
|
||||
item(
|
||||
contentType = "library_list_empty",
|
||||
) {
|
||||
LibraryPagerEmptyScreen(searchQuery, hasActiveFilters, contentPadding)
|
||||
}
|
||||
} else {
|
||||
items(
|
||||
items = items,
|
||||
contentType = { "library_list_item" },
|
||||
) { libraryItem ->
|
||||
val manga = libraryItem.libraryManga.manga
|
||||
MangaListItem(
|
||||
isSelected = selection.fastAny { it.id == libraryItem.libraryManga.id },
|
||||
title = manga.title,
|
||||
coverData = MangaCover(
|
||||
mangaId = manga.id,
|
||||
sourceId = manga.source,
|
||||
isMangaFavorite = manga.favorite,
|
||||
url = manga.thumbnailUrl,
|
||||
lastModified = manga.coverLastModified,
|
||||
),
|
||||
badge = {
|
||||
DownloadsBadge(count = libraryItem.downloadCount.toInt())
|
||||
UnreadBadge(count = libraryItem.unreadCount.toInt())
|
||||
LanguageBadge(
|
||||
isLocal = libraryItem.isLocal,
|
||||
sourceLanguage = libraryItem.sourceLanguage,
|
||||
)
|
||||
},
|
||||
onLongClick = { onLongClick(libraryItem.libraryManga) },
|
||||
onClick = { onClick(libraryItem.libraryManga) },
|
||||
onClickContinueReading = if (onClickContinueReading != null) {
|
||||
{ onClickContinueReading(libraryItem.libraryManga) }
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,6 @@ fun LibraryPager(
|
||||
}
|
||||
val library = getLibraryForPage(page)
|
||||
|
||||
if (library.isEmpty()) {
|
||||
LibraryPagerEmptyScreen(searchQuery, hasActiveFilters, contentPadding)
|
||||
return@HorizontalPager
|
||||
}
|
||||
|
||||
val displayMode = getDisplayModeForPage(page)
|
||||
val columns by if (displayMode != LibraryDisplayMode.List) {
|
||||
val configuration = LocalConfiguration.current
|
||||
@@ -74,6 +69,7 @@ fun LibraryPager(
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
searchQuery = searchQuery,
|
||||
onGlobalSearchClicked = onGlobalSearchClicked,
|
||||
hasActiveFilters = hasActiveFilters,
|
||||
)
|
||||
}
|
||||
LibraryDisplayMode.CompactGrid, LibraryDisplayMode.CoverOnlyGrid -> {
|
||||
@@ -88,6 +84,7 @@ fun LibraryPager(
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
searchQuery = searchQuery,
|
||||
onGlobalSearchClicked = onGlobalSearchClicked,
|
||||
hasActiveFilters = hasActiveFilters,
|
||||
)
|
||||
}
|
||||
LibraryDisplayMode.ComfortableGrid -> {
|
||||
@@ -101,6 +98,7 @@ fun LibraryPager(
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
searchQuery = searchQuery,
|
||||
onGlobalSearchClicked = onGlobalSearchClicked,
|
||||
hasActiveFilters = hasActiveFilters,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -108,7 +106,7 @@ fun LibraryPager(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LibraryPagerEmptyScreen(
|
||||
internal fun LibraryPagerEmptyScreen(
|
||||
searchQuery: String?,
|
||||
hasActiveFilters: Boolean,
|
||||
contentPadding: PaddingValues,
|
||||
@@ -119,6 +117,7 @@ private fun LibraryPagerEmptyScreen(
|
||||
else -> R.string.information_no_manga_category
|
||||
}
|
||||
|
||||
// TODO: vertically center this better
|
||||
EmptyScreen(
|
||||
textResource = msg,
|
||||
modifier = Modifier.padding(contentPadding),
|
||||
|
||||
Reference in New Issue
Block a user