LibraryScreen.kt 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package eu.kanade.presentation.library
  2. import androidx.compose.foundation.layout.safeDrawingPadding
  3. import androidx.compose.runtime.Composable
  4. import androidx.compose.runtime.getValue
  5. import androidx.compose.ui.Modifier
  6. import eu.kanade.domain.category.model.Category
  7. import eu.kanade.presentation.components.LibraryBottomActionMenu
  8. import eu.kanade.presentation.components.Scaffold
  9. import eu.kanade.presentation.library.components.LibraryContent
  10. import eu.kanade.presentation.library.components.LibraryToolbar
  11. import eu.kanade.tachiyomi.source.LocalSource
  12. import eu.kanade.tachiyomi.ui.library.LibraryPresenter
  13. @Composable
  14. fun LibraryScreen(
  15. presenter: LibraryPresenter,
  16. onMangaClicked: (Long) -> Unit,
  17. onGlobalSearchClicked: () -> Unit,
  18. onChangeCategoryClicked: () -> Unit,
  19. onMarkAsReadClicked: () -> Unit,
  20. onMarkAsUnreadClicked: () -> Unit,
  21. onDownloadClicked: () -> Unit,
  22. onDeleteClicked: () -> Unit,
  23. onClickUnselectAll: () -> Unit,
  24. onClickSelectAll: () -> Unit,
  25. onClickInvertSelection: () -> Unit,
  26. onClickFilter: () -> Unit,
  27. onClickRefresh: (Category?) -> Unit,
  28. ) {
  29. Scaffold(
  30. modifier = Modifier.safeDrawingPadding(),
  31. topBar = {
  32. val title by presenter.getToolbarTitle()
  33. LibraryToolbar(
  34. state = presenter,
  35. title = title,
  36. onClickUnselectAll = onClickUnselectAll,
  37. onClickSelectAll = onClickSelectAll,
  38. onClickInvertSelection = onClickInvertSelection,
  39. onClickFilter = onClickFilter,
  40. onClickRefresh = { onClickRefresh(null) },
  41. )
  42. },
  43. bottomBar = {
  44. LibraryBottomActionMenu(
  45. visible = presenter.selectionMode,
  46. onChangeCategoryClicked = onChangeCategoryClicked,
  47. onMarkAsReadClicked = onMarkAsReadClicked,
  48. onMarkAsUnreadClicked = onMarkAsUnreadClicked,
  49. onDownloadClicked = onDownloadClicked,
  50. onDeleteClicked = onDeleteClicked.takeIf { presenter.selection.none { it.source == LocalSource.ID } },
  51. )
  52. },
  53. ) { paddingValues ->
  54. LibraryContent(
  55. state = presenter,
  56. contentPadding = paddingValues,
  57. currentPage = presenter.activeCategory,
  58. isLibraryEmpty = presenter.loadedManga.isEmpty(),
  59. showPageTabs = presenter.tabVisibility,
  60. showMangaCount = presenter.mangaCountVisibility,
  61. onChangeCurrentPage = { presenter.activeCategory = it },
  62. onMangaClicked = onMangaClicked,
  63. onToggleSelection = { presenter.toggleSelection(it) },
  64. onRefresh = onClickRefresh,
  65. onGlobalSearchClicked = onGlobalSearchClicked,
  66. getNumberOfMangaForCategory = { presenter.getMangaCountForCategory(it) },
  67. getDisplayModeForPage = { presenter.getDisplayMode(index = it) },
  68. getColumnsForOrientation = { presenter.getColumnsPreferenceForCurrentOrientation(it) },
  69. getLibraryForPage = { presenter.getMangaForCategory(page = it) },
  70. isIncognitoMode = presenter.isIncognitoMode,
  71. isDownloadOnly = presenter.isDownloadOnly,
  72. )
  73. }
  74. }