2022-07-23 01:05:50 +02:00
|
|
|
package eu.kanade.presentation.library
|
|
|
|
|
|
2022-10-09 21:52:56 +02:00
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
2022-10-29 17:43:51 +02:00
|
|
|
import androidx.compose.material.icons.outlined.HelpOutline
|
2022-07-23 01:05:50 +02:00
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.getValue
|
2022-10-09 21:52:56 +02:00
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.platform.LocalUriHandler
|
2022-10-30 17:27:12 +01:00
|
|
|
import androidx.compose.ui.util.fastAll
|
2022-07-24 14:48:54 +02:00
|
|
|
import eu.kanade.domain.category.model.Category
|
2022-10-01 17:30:51 +02:00
|
|
|
import eu.kanade.domain.library.model.LibraryManga
|
2022-10-14 22:13:50 +02:00
|
|
|
import eu.kanade.domain.manga.model.isLocal
|
2022-10-09 21:52:56 +02:00
|
|
|
import eu.kanade.presentation.components.EmptyScreen
|
|
|
|
|
import eu.kanade.presentation.components.EmptyScreenAction
|
2022-07-23 01:05:50 +02:00
|
|
|
import eu.kanade.presentation.components.LibraryBottomActionMenu
|
2022-07-27 15:00:09 +02:00
|
|
|
import eu.kanade.presentation.components.LoadingScreen
|
2022-07-23 01:05:50 +02:00
|
|
|
import eu.kanade.presentation.components.Scaffold
|
|
|
|
|
import eu.kanade.presentation.library.components.LibraryContent
|
|
|
|
|
import eu.kanade.presentation.library.components.LibraryToolbar
|
2022-10-31 03:27:48 +01:00
|
|
|
import eu.kanade.presentation.manga.DownloadAction
|
2022-10-09 21:52:56 +02:00
|
|
|
import eu.kanade.tachiyomi.R
|
2022-07-23 01:05:50 +02:00
|
|
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
2022-10-09 21:52:56 +02:00
|
|
|
import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView
|
2022-07-23 01:05:50 +02:00
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun LibraryScreen(
|
|
|
|
|
presenter: LibraryPresenter,
|
|
|
|
|
onMangaClicked: (Long) -> Unit,
|
|
|
|
|
onGlobalSearchClicked: () -> Unit,
|
|
|
|
|
onChangeCategoryClicked: () -> Unit,
|
|
|
|
|
onMarkAsReadClicked: () -> Unit,
|
|
|
|
|
onMarkAsUnreadClicked: () -> Unit,
|
2022-10-31 03:27:48 +01:00
|
|
|
onDownloadClicked: (DownloadAction) -> Unit,
|
2022-07-23 01:05:50 +02:00
|
|
|
onDeleteClicked: () -> Unit,
|
|
|
|
|
onClickUnselectAll: () -> Unit,
|
|
|
|
|
onClickSelectAll: () -> Unit,
|
|
|
|
|
onClickInvertSelection: () -> Unit,
|
|
|
|
|
onClickFilter: () -> Unit,
|
2022-08-18 15:01:10 +02:00
|
|
|
onClickRefresh: (Category?) -> Boolean,
|
2022-10-30 15:57:33 +01:00
|
|
|
onClickOpenRandomManga: () -> Unit,
|
2022-07-23 01:05:50 +02:00
|
|
|
// SY -->
|
|
|
|
|
onClickCleanTitles: () -> Unit,
|
|
|
|
|
onClickMigrate: () -> Unit,
|
|
|
|
|
onClickAddToMangaDex: () -> Unit,
|
|
|
|
|
onClickSyncExh: () -> Unit,
|
|
|
|
|
onOpenReader: (LibraryManga) -> Unit,
|
|
|
|
|
// SY <--
|
|
|
|
|
) {
|
2022-10-25 15:40:45 +02: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) },
|
2022-10-30 15:57:33 +01:00
|
|
|
onClickOpenRandomManga = onClickOpenRandomManga,
|
2022-10-25 15:40:45 +02:00
|
|
|
// SY -->
|
|
|
|
|
onClickSyncExh = onClickSyncExh,
|
|
|
|
|
// SY <--
|
|
|
|
|
scrollBehavior = scrollBehavior.takeIf { !tabVisible }, // For scroll overlay when no tab
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
bottomBar = {
|
|
|
|
|
LibraryBottomActionMenu(
|
|
|
|
|
visible = presenter.selectionMode,
|
|
|
|
|
onChangeCategoryClicked = onChangeCategoryClicked,
|
|
|
|
|
onMarkAsReadClicked = onMarkAsReadClicked,
|
|
|
|
|
onMarkAsUnreadClicked = onMarkAsUnreadClicked,
|
2022-10-30 17:27:12 +01:00
|
|
|
onDownloadClicked = onDownloadClicked.takeIf { presenter.selection.fastAll { !it.manga.isLocal() } },
|
2022-10-25 15:40:45 +02:00
|
|
|
onDeleteClicked = onDeleteClicked,
|
|
|
|
|
// SY -->
|
|
|
|
|
onClickCleanTitles = onClickCleanTitles.takeIf { presenter.showCleanTitles },
|
|
|
|
|
onClickMigrate = onClickMigrate,
|
|
|
|
|
onClickAddToMangaDex = onClickAddToMangaDex.takeIf { presenter.showAddToMangadex },
|
|
|
|
|
// SY <--
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
) { paddingValues ->
|
|
|
|
|
if (presenter.isLoading) {
|
|
|
|
|
LoadingScreen()
|
|
|
|
|
return@Scaffold
|
|
|
|
|
}
|
2022-10-09 21:52:56 +02:00
|
|
|
|
2022-10-25 15:40:45 +02: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,
|
2022-10-29 17:43:51 +02:00
|
|
|
icon = Icons.Outlined.HelpOutline,
|
2022-10-25 15:40:45 +02:00
|
|
|
onClick = { handler.openUri("https://tachiyomi.org/help/guides/getting-started") },
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
return@Scaffold
|
2022-07-27 15:00:09 +02:00
|
|
|
}
|
2022-10-25 15:40:45 +02: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) },
|
|
|
|
|
// SY -->
|
|
|
|
|
getDisplayModeForPage = { presenter.getDisplayMode(index = it) },
|
|
|
|
|
// SY <--
|
|
|
|
|
getColumnsForOrientation = { presenter.getColumnsPreferenceForCurrentOrientation(it) },
|
|
|
|
|
getLibraryForPage = { presenter.getMangaForCategory(page = it) },
|
|
|
|
|
showDownloadBadges = presenter.showDownloadBadges,
|
|
|
|
|
showUnreadBadges = presenter.showUnreadBadges,
|
|
|
|
|
showLocalBadges = presenter.showLocalBadges,
|
|
|
|
|
showLanguageBadges = presenter.showLanguageBadges,
|
|
|
|
|
// SY -->
|
|
|
|
|
showStartReadingButton = presenter.showStartReadingButton,
|
|
|
|
|
// SY <--
|
|
|
|
|
isIncognitoMode = presenter.isIncognitoMode,
|
|
|
|
|
isDownloadOnly = presenter.isDownloadOnly,
|
|
|
|
|
// SY -->
|
|
|
|
|
onOpenReader = onOpenReader,
|
|
|
|
|
getCategoryName = presenter::getCategoryName,
|
|
|
|
|
// SY <--
|
|
|
|
|
)
|
2022-07-23 01:05:50 +02:00
|
|
|
}
|
|
|
|
|
}
|