LibraryCoverOnlyGrid.kt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package eu.kanade.presentation.library.components
  2. import androidx.compose.foundation.combinedClickable
  3. import androidx.compose.foundation.lazy.grid.items
  4. import androidx.compose.runtime.Composable
  5. import androidx.compose.ui.Modifier
  6. import eu.kanade.tachiyomi.data.database.models.LibraryManga
  7. import eu.kanade.tachiyomi.ui.library.LibraryItem
  8. @Composable
  9. fun LibraryCoverOnlyGrid(
  10. items: List<LibraryItem>,
  11. columns: Int,
  12. selection: List<LibraryManga>,
  13. onClick: (LibraryManga) -> Unit,
  14. onLongClick: (LibraryManga) -> Unit,
  15. ) {
  16. LazyLibraryGrid(
  17. columns = columns,
  18. ) {
  19. items(
  20. items = items,
  21. key = {
  22. it.manga.id!!
  23. },
  24. ) { libraryItem ->
  25. LibraryCoverOnlyGridItem(
  26. item = libraryItem,
  27. isSelected = libraryItem.manga in selection,
  28. onClick = onClick,
  29. onLongClick = onLongClick,
  30. )
  31. }
  32. }
  33. }
  34. @Composable
  35. fun LibraryCoverOnlyGridItem(
  36. item: LibraryItem,
  37. isSelected: Boolean,
  38. onClick: (LibraryManga) -> Unit,
  39. onLongClick: (LibraryManga) -> Unit,
  40. ) {
  41. val manga = item.manga
  42. LibraryGridCover(
  43. modifier = Modifier
  44. .selectedOutline(isSelected)
  45. .combinedClickable(
  46. onClick = {
  47. onClick(manga)
  48. },
  49. onLongClick = {
  50. onLongClick(manga)
  51. },
  52. ),
  53. mangaCover = eu.kanade.domain.manga.model.MangaCover(
  54. manga.id!!,
  55. manga.source,
  56. manga.favorite,
  57. manga.thumbnail_url,
  58. manga.cover_last_modified,
  59. ),
  60. downloadCount = item.downloadCount,
  61. unreadCount = item.unreadCount,
  62. isLocal = item.isLocal,
  63. language = item.sourceLanguage,
  64. )
  65. }