2022-07-23 07:05:50 +08:00
|
|
|
package eu.kanade.presentation.library
|
|
|
|
|
2022-10-10 03:52:56 +08:00
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
import androidx.compose.material.icons.filled.HelpOutline
|
2022-07-23 07:05:50 +08:00
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.getValue
|
2022-10-10 03:52:56 +08:00
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.platform.LocalUriHandler
|
2022-07-24 20:48:54 +08:00
|
|
|
import eu.kanade.domain.category.model.Category
|
2022-09-20 11:55:07 +08:00
|
|
|
import eu.kanade.domain.library.model.display
|
2022-10-15 04:13:50 +08:00
|
|
|
import eu.kanade.domain.manga.model.isLocal
|
2022-10-10 03:52:56 +08:00
|
|
|
import eu.kanade.presentation.components.EmptyScreen
|
|
|
|
import eu.kanade.presentation.components.EmptyScreenAction
|
2022-07-23 07:05:50 +08:00
|
|
|
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
2022-07-27 21:00:09 +08:00
|
|
|
import eu.kanade.presentation.components.LoadingScreen
|
2022-07-23 07:05:50 +08:00
|
|
|
import eu.kanade.presentation.components.Scaffold
|
|
|
|
import eu.kanade.presentation.library.components.LibraryContent
|
|
|
|
import eu.kanade.presentation.library.components.LibraryToolbar
|
2022-10-10 03:52:56 +08:00
|
|
|
import eu.kanade.tachiyomi.R
|
2022-07-23 07:05:50 +08:00
|
|
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
2022-10-10 03:52:56 +08:00
|
|
|
import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView
|
2022-07-23 07:05:50 +08:00
|
|
|
|
|
|
|
@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-08-18 21:01:10 +08:00
|
|
|
onClickRefresh: (Category?) -> Boolean,
|
2022-07-23 07:05:50 +08:00
|
|
|
) {
|
2022-10-25 21:40:45 +08:00
|
|
|
Scaffold(
|
|
|
|
topBar = { scrollBehavior ->
|
|
|
|
val title by presenter.getToolbarTitle()
|
|
|
|
val tabVisible = presenter.tabVisibility && presenter.categories.size > 1
|
|
|
|
LibraryToolbar(
|
|
|
|
state = presenter,
|
|
|
|
title = title,
|
|
|
|
incognitoMode = !tabVisible && presenter.isIncognitoMode,
|
|
|
|
downloadedOnlyMode = !tabVisible && presenter.isDownloadOnly,
|
|
|
|
onClickUnselectAll = onClickUnselectAll,
|
|
|
|
onClickSelectAll = onClickSelectAll,
|
|
|
|
onClickInvertSelection = onClickInvertSelection,
|
|
|
|
onClickFilter = onClickFilter,
|
|
|
|
onClickRefresh = { onClickRefresh(null) },
|
|
|
|
scrollBehavior = scrollBehavior.takeIf { !tabVisible }, // For scroll overlay when no tab
|
|
|
|
)
|
|
|
|
},
|
|
|
|
bottomBar = {
|
|
|
|
LibraryBottomActionMenu(
|
|
|
|
visible = presenter.selectionMode,
|
|
|
|
onChangeCategoryClicked = onChangeCategoryClicked,
|
|
|
|
onMarkAsReadClicked = onMarkAsReadClicked,
|
|
|
|
onMarkAsUnreadClicked = onMarkAsUnreadClicked,
|
|
|
|
onDownloadClicked = onDownloadClicked.takeIf { presenter.selection.none { it.manga.isLocal() } },
|
|
|
|
onDeleteClicked = onDeleteClicked,
|
|
|
|
)
|
|
|
|
},
|
|
|
|
) { paddingValues ->
|
|
|
|
if (presenter.isLoading) {
|
|
|
|
LoadingScreen()
|
|
|
|
return@Scaffold
|
|
|
|
}
|
2022-10-10 03:52:56 +08:00
|
|
|
|
2022-10-25 21:40:45 +08:00
|
|
|
val contentPadding = TachiyomiBottomNavigationView.withBottomNavPadding(paddingValues)
|
|
|
|
if (presenter.searchQuery.isNullOrEmpty() && presenter.isLibraryEmpty) {
|
|
|
|
val handler = LocalUriHandler.current
|
|
|
|
EmptyScreen(
|
|
|
|
textResource = R.string.information_empty_library,
|
|
|
|
modifier = Modifier.padding(contentPadding),
|
|
|
|
actions = listOf(
|
|
|
|
EmptyScreenAction(
|
|
|
|
stringResId = R.string.getting_started_guide,
|
|
|
|
icon = Icons.Default.HelpOutline,
|
|
|
|
onClick = { handler.openUri("https://tachiyomi.org/help/guides/getting-started") },
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
return@Scaffold
|
2022-07-27 21:00:09 +08:00
|
|
|
}
|
2022-10-25 21:40:45 +08:00
|
|
|
|
|
|
|
LibraryContent(
|
|
|
|
state = presenter,
|
|
|
|
contentPadding = contentPadding,
|
|
|
|
currentPage = { presenter.activeCategory },
|
|
|
|
isLibraryEmpty = presenter.isLibraryEmpty,
|
|
|
|
showPageTabs = presenter.tabVisibility,
|
|
|
|
showMangaCount = presenter.mangaCountVisibility,
|
|
|
|
onChangeCurrentPage = { presenter.activeCategory = it },
|
|
|
|
onMangaClicked = onMangaClicked,
|
|
|
|
onToggleSelection = { presenter.toggleSelection(it) },
|
|
|
|
onToggleRangeSelection = { presenter.toggleRangeSelection(it) },
|
|
|
|
onRefresh = onClickRefresh,
|
|
|
|
onGlobalSearchClicked = onGlobalSearchClicked,
|
|
|
|
getNumberOfMangaForCategory = { presenter.getMangaCountForCategory(it) },
|
|
|
|
getDisplayModeForPage = { presenter.categories[it].display },
|
|
|
|
getColumnsForOrientation = { presenter.getColumnsPreferenceForCurrentOrientation(it) },
|
|
|
|
getLibraryForPage = { presenter.getMangaForCategory(page = it) },
|
|
|
|
showDownloadBadges = presenter.showDownloadBadges,
|
|
|
|
showUnreadBadges = presenter.showUnreadBadges,
|
|
|
|
showLocalBadges = presenter.showLocalBadges,
|
|
|
|
showLanguageBadges = presenter.showLanguageBadges,
|
|
|
|
isIncognitoMode = presenter.isIncognitoMode,
|
|
|
|
isDownloadOnly = presenter.isDownloadOnly,
|
|
|
|
)
|
2022-07-23 07:05:50 +08:00
|
|
|
}
|
|
|
|
}
|