Fast browse for RecommendsScreen & remove bulk-selection on it
This commit is contained in:
parent
aba9faff57
commit
7e16b56911
3 changed files with 40 additions and 97 deletions
|
|
@ -56,18 +56,37 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen() {
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
val onClickItem = { manga: Manga ->
|
val onClickItem = { manga: Manga ->
|
||||||
navigator.push(
|
|
||||||
when (manga.source) {
|
when (manga.source) {
|
||||||
-1L -> SourcesScreen(SourcesScreen.SmartSearchConfig(manga.ogTitle))
|
-1L -> navigator.push(
|
||||||
else -> MangaScreen(manga.id, true)
|
SourcesScreen(SourcesScreen.SmartSearchConfig(manga.ogTitle)),
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
else -> {
|
||||||
|
// KMK -->
|
||||||
|
scope.launchIO {
|
||||||
|
val localManga = screenModel.networkToLocalManga.getLocal(manga)
|
||||||
|
navigator.push(
|
||||||
|
// KMK <--
|
||||||
|
MangaScreen(localManga.id, true),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val onLongClickItem = { manga: Manga ->
|
val onLongClickItem = { manga: Manga ->
|
||||||
when (manga.source) {
|
when (manga.source) {
|
||||||
-1L -> WebViewActivity.newIntent(context, manga.url, title = manga.title).let(context::startActivity)
|
-1L -> WebViewActivity.newIntent(context, manga.url, title = manga.title).let(context::startActivity)
|
||||||
else -> onClickItem(manga)
|
else -> {
|
||||||
|
// KMK -->
|
||||||
|
scope.launchIO {
|
||||||
|
val localManga = screenModel.networkToLocalManga.getLocal(manga)
|
||||||
|
bulkFavoriteScreenModel.addRemoveManga(
|
||||||
|
localManga,
|
||||||
|
haptic,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// KMK <--
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,33 +106,8 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen() {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClickItem = {
|
onClickItem = { onClickItem(it) },
|
||||||
// KMK -->
|
onLongClickItem = { onLongClickItem(it) },
|
||||||
scope.launchIO {
|
|
||||||
val manga = screenModel.networkToLocalManga.getLocal(it)
|
|
||||||
if (bulkFavoriteState.selectionMode) {
|
|
||||||
bulkFavoriteScreenModel.toggleSelection(manga)
|
|
||||||
} else {
|
|
||||||
// KMK <--
|
|
||||||
onClickItem(manga)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLongClickItem = {
|
|
||||||
// KMK -->
|
|
||||||
scope.launchIO {
|
|
||||||
val manga = screenModel.networkToLocalManga.getLocal(it)
|
|
||||||
if (!bulkFavoriteState.selectionMode) {
|
|
||||||
bulkFavoriteScreenModel.addRemoveManga(manga, haptic)
|
|
||||||
} else {
|
|
||||||
// KMK <--
|
|
||||||
onLongClickItem(manga)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// KMK -->
|
|
||||||
bulkFavoriteScreenModel = bulkFavoriteScreenModel,
|
|
||||||
// KMK <--
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
|
|
|
||||||
|
|
@ -74,13 +74,11 @@ open class RecommendsScreenModel(
|
||||||
|
|
||||||
val titles = page.mangas.map {
|
val titles = page.mangas.map {
|
||||||
val recSourceId = recSource.associatedSourceId
|
val recSourceId = recSource.associatedSourceId
|
||||||
if (recSourceId != null) {
|
// KMK -->
|
||||||
// If the recommendation is associated with a source, resolve it
|
// If the recommendation is associated with a source, resolve it
|
||||||
networkToLocalManga.await(it.toDomainManga(recSourceId))
|
|
||||||
} else {
|
|
||||||
// Otherwise, skip this step. The user will be prompted to choose a source via SmartSearch
|
// Otherwise, skip this step. The user will be prompted to choose a source via SmartSearch
|
||||||
it.toDomainManga(-1)
|
it.toDomainManga(recSourceId ?: -1)
|
||||||
}
|
// KMK <--
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,13 @@ import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.collectAsState
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar
|
|
||||||
import eu.kanade.presentation.browse.components.GlobalSearchCardRow
|
import eu.kanade.presentation.browse.components.GlobalSearchCardRow
|
||||||
import eu.kanade.presentation.browse.components.GlobalSearchErrorResultItem
|
import eu.kanade.presentation.browse.components.GlobalSearchErrorResultItem
|
||||||
import eu.kanade.presentation.browse.components.GlobalSearchLoadingResultItem
|
import eu.kanade.presentation.browse.components.GlobalSearchLoadingResultItem
|
||||||
import eu.kanade.presentation.browse.components.GlobalSearchResultItem
|
import eu.kanade.presentation.browse.components.GlobalSearchResultItem
|
||||||
import eu.kanade.presentation.components.BulkSelectionToolbar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.util.formattedMessage
|
import eu.kanade.presentation.util.formattedMessage
|
||||||
import eu.kanade.tachiyomi.ui.browse.BulkFavoriteScreenModel
|
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SearchItemResult
|
|
||||||
import exh.recs.RecommendationItemResult
|
import exh.recs.RecommendationItemResult
|
||||||
import exh.recs.RecommendsScreenModel
|
import exh.recs.RecommendsScreenModel
|
||||||
import exh.recs.sources.RecommendationPagingSource
|
import exh.recs.sources.RecommendationPagingSource
|
||||||
|
|
@ -35,52 +30,14 @@ fun RecommendsScreen(
|
||||||
onClickSource: (RecommendationPagingSource) -> Unit,
|
onClickSource: (RecommendationPagingSource) -> Unit,
|
||||||
onClickItem: (Manga) -> Unit,
|
onClickItem: (Manga) -> Unit,
|
||||||
onLongClickItem: (Manga) -> Unit,
|
onLongClickItem: (Manga) -> Unit,
|
||||||
// KMK -->
|
|
||||||
bulkFavoriteScreenModel: BulkFavoriteScreenModel,
|
|
||||||
// KMK <--
|
|
||||||
) {
|
) {
|
||||||
// KMK -->
|
|
||||||
val bulkFavoriteState by bulkFavoriteScreenModel.state.collectAsState()
|
|
||||||
// KMK <--
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = { scrollBehavior ->
|
topBar = { scrollBehavior ->
|
||||||
// KMK -->
|
AppBar(
|
||||||
if (bulkFavoriteState.selectionMode) {
|
|
||||||
BulkSelectionToolbar(
|
|
||||||
selectedCount = bulkFavoriteState.selection.size,
|
|
||||||
isRunning = bulkFavoriteState.isRunning,
|
|
||||||
onClickClearSelection = bulkFavoriteScreenModel::toggleSelectionMode,
|
|
||||||
onChangeCategoryClick = bulkFavoriteScreenModel::addFavorite,
|
|
||||||
onSelectAll = {
|
|
||||||
state.filteredItems.forEach { (_, result) ->
|
|
||||||
if (result is RecommendationItemResult.Success) {
|
|
||||||
result.result.forEach { manga ->
|
|
||||||
bulkFavoriteScreenModel.select(manga)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onReverseSelection = {
|
|
||||||
bulkFavoriteScreenModel.reverseSelection(
|
|
||||||
state.filteredItems.values
|
|
||||||
.filterIsInstance<SearchItemResult.Success>()
|
|
||||||
.flatMap { it.result },
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
BrowseSourceSimpleToolbar(
|
|
||||||
displayMode = null,
|
|
||||||
onDisplayModeChange = {},
|
|
||||||
toggleSelectionMode = bulkFavoriteScreenModel::toggleSelectionMode,
|
|
||||||
isRunning = bulkFavoriteState.isRunning,
|
|
||||||
// KMK <--
|
|
||||||
title = stringResource(SYMR.strings.similar, manga?.title.orEmpty()),
|
title = stringResource(SYMR.strings.similar, manga?.title.orEmpty()),
|
||||||
scrollBehavior = scrollBehavior,
|
scrollBehavior = scrollBehavior,
|
||||||
navigateUp = navigateUp,
|
navigateUp = navigateUp,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
RecommendsContent(
|
RecommendsContent(
|
||||||
|
|
@ -90,9 +47,6 @@ fun RecommendsScreen(
|
||||||
onClickSource = onClickSource,
|
onClickSource = onClickSource,
|
||||||
onClickItem = onClickItem,
|
onClickItem = onClickItem,
|
||||||
onLongClickItem = onLongClickItem,
|
onLongClickItem = onLongClickItem,
|
||||||
// KMK -->
|
|
||||||
selection = bulkFavoriteState.selection,
|
|
||||||
// KMK <--
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,9 +59,6 @@ internal fun RecommendsContent(
|
||||||
onClickSource: (RecommendationPagingSource) -> Unit,
|
onClickSource: (RecommendationPagingSource) -> Unit,
|
||||||
onClickItem: (Manga) -> Unit,
|
onClickItem: (Manga) -> Unit,
|
||||||
onLongClickItem: (Manga) -> Unit,
|
onLongClickItem: (Manga) -> Unit,
|
||||||
// KMK -->
|
|
||||||
selection: List<Manga>,
|
|
||||||
// KMK <--
|
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
|
|
@ -130,7 +81,7 @@ internal fun RecommendsContent(
|
||||||
onClick = onClickItem,
|
onClick = onClickItem,
|
||||||
onLongClick = onLongClickItem,
|
onLongClick = onLongClickItem,
|
||||||
// KMK -->
|
// KMK -->
|
||||||
selection = selection,
|
selection = emptyList(),
|
||||||
// KMK <--
|
// KMK <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue