2022-07-23 07:05:50 +08:00
|
|
|
package eu.kanade.presentation.library
|
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.getValue
|
2022-07-24 20:48:54 +08:00
|
|
|
import eu.kanade.domain.category.model.Category
|
2022-07-23 07:05:50 +08:00
|
|
|
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
|
|
|
import eu.kanade.presentation.components.Scaffold
|
|
|
|
import eu.kanade.presentation.library.components.LibraryContent
|
|
|
|
import eu.kanade.presentation.library.components.LibraryToolbar
|
2022-07-23 21:58:05 +08:00
|
|
|
import eu.kanade.tachiyomi.source.LocalSource
|
2022-07-23 07:05:50 +08:00
|
|
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun LibraryScreen(
|
|
|
|
presenter: LibraryPresenter,
|
|
|
|
onMangaClicked: (Long) -> Unit,
|
|
|
|
onGlobalSearchClicked: () -> Unit,
|
|
|
|
onChangeCategoryClicked: () -> Unit,
|
|
|
|
onMarkAsReadClicked: () -> Unit,
|
|
|
|
onMarkAsUnreadClicked: () -> Unit,
|
|
|
|
onDownloadClicked: () -> Unit,
|
|
|
|
onDeleteClicked: () -> Unit,
|
|
|
|
onClickUnselectAll: () -> Unit,
|
|
|
|
onClickSelectAll: () -> Unit,
|
|
|
|
onClickInvertSelection: () -> Unit,
|
|
|
|
onClickFilter: () -> Unit,
|
2022-07-24 20:48:54 +08:00
|
|
|
onClickRefresh: (Category?) -> Unit,
|
2022-07-23 07:05:50 +08:00
|
|
|
) {
|
|
|
|
Scaffold(
|
|
|
|
topBar = {
|
|
|
|
val title by presenter.getToolbarTitle()
|
|
|
|
LibraryToolbar(
|
|
|
|
state = presenter,
|
|
|
|
title = title,
|
|
|
|
onClickUnselectAll = onClickUnselectAll,
|
|
|
|
onClickSelectAll = onClickSelectAll,
|
|
|
|
onClickInvertSelection = onClickInvertSelection,
|
|
|
|
onClickFilter = onClickFilter,
|
2022-07-24 20:48:54 +08:00
|
|
|
onClickRefresh = { onClickRefresh(null) },
|
2022-07-23 07:05:50 +08:00
|
|
|
)
|
|
|
|
},
|
|
|
|
bottomBar = {
|
|
|
|
LibraryBottomActionMenu(
|
|
|
|
visible = presenter.selectionMode,
|
|
|
|
onChangeCategoryClicked = onChangeCategoryClicked,
|
|
|
|
onMarkAsReadClicked = onMarkAsReadClicked,
|
|
|
|
onMarkAsUnreadClicked = onMarkAsUnreadClicked,
|
|
|
|
onDownloadClicked = onDownloadClicked,
|
2022-07-23 21:58:05 +08:00
|
|
|
onDeleteClicked = onDeleteClicked.takeIf { presenter.selection.none { it.source == LocalSource.ID } },
|
2022-07-23 07:05:50 +08:00
|
|
|
)
|
|
|
|
},
|
|
|
|
) { paddingValues ->
|
|
|
|
LibraryContent(
|
|
|
|
state = presenter,
|
|
|
|
contentPadding = paddingValues,
|
|
|
|
currentPage = presenter.activeCategory,
|
|
|
|
isLibraryEmpty = presenter.loadedManga.isEmpty(),
|
|
|
|
showPageTabs = presenter.tabVisibility,
|
|
|
|
showMangaCount = presenter.mangaCountVisibility,
|
|
|
|
onChangeCurrentPage = { presenter.activeCategory = it },
|
|
|
|
onMangaClicked = onMangaClicked,
|
|
|
|
onToggleSelection = { presenter.toggleSelection(it) },
|
|
|
|
onRefresh = onClickRefresh,
|
|
|
|
onGlobalSearchClicked = onGlobalSearchClicked,
|
|
|
|
getNumberOfMangaForCategory = { presenter.getMangaCountForCategory(it) },
|
|
|
|
getDisplayModeForPage = { presenter.getDisplayMode(index = it) },
|
|
|
|
getColumnsForOrientation = { presenter.getColumnsPreferenceForCurrentOrientation(it) },
|
|
|
|
getLibraryForPage = { presenter.getMangaForCategory(page = it) },
|
|
|
|
isIncognitoMode = presenter.isIncognitoMode,
|
|
|
|
isDownloadOnly = presenter.isDownloadOnly,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|