mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 09:41:51 +01:00
Disable ChapterHeader
& ChapterDownloadIndicator
click when in selection mode (#8350)
* Disable `ChapterHeader` click when in selection mode * Disable `ChapterDownloadIndicator` click when in selection mode * Review changes * Merge remote-tracking branch 'origin/master' into patch-7 * Merge remote-tracking branch 'origin/master' into patch-7 * Revert back to old implementation
This commit is contained in:
parent
33e90d6449
commit
8dce7b3e9e
@ -43,26 +43,41 @@ enum class ChapterDownloadAction {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChapterDownloadIndicator(
|
fun ChapterDownloadIndicator(
|
||||||
|
enabled: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
downloadStateProvider: () -> Download.State,
|
downloadStateProvider: () -> Download.State,
|
||||||
downloadProgressProvider: () -> Int,
|
downloadProgressProvider: () -> Int,
|
||||||
onClick: (ChapterDownloadAction) -> Unit,
|
onClick: (ChapterDownloadAction) -> Unit,
|
||||||
) {
|
) {
|
||||||
when (val downloadState = downloadStateProvider()) {
|
when (val downloadState = downloadStateProvider()) {
|
||||||
Download.State.NOT_DOWNLOADED -> NotDownloadedIndicator(modifier = modifier, onClick = onClick)
|
Download.State.NOT_DOWNLOADED -> NotDownloadedIndicator(
|
||||||
|
enabled = enabled,
|
||||||
|
modifier = modifier,
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
Download.State.QUEUE, Download.State.DOWNLOADING -> DownloadingIndicator(
|
Download.State.QUEUE, Download.State.DOWNLOADING -> DownloadingIndicator(
|
||||||
|
enabled = enabled,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
downloadState = downloadState,
|
downloadState = downloadState,
|
||||||
downloadProgressProvider = downloadProgressProvider,
|
downloadProgressProvider = downloadProgressProvider,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
)
|
)
|
||||||
Download.State.DOWNLOADED -> DownloadedIndicator(modifier = modifier, onClick = onClick)
|
Download.State.DOWNLOADED -> DownloadedIndicator(
|
||||||
Download.State.ERROR -> ErrorIndicator(modifier = modifier, onClick = onClick)
|
enabled = enabled,
|
||||||
|
modifier = modifier,
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
|
Download.State.ERROR -> ErrorIndicator(
|
||||||
|
enabled = enabled,
|
||||||
|
modifier = modifier,
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun NotDownloadedIndicator(
|
private fun NotDownloadedIndicator(
|
||||||
|
enabled: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onClick: (ChapterDownloadAction) -> Unit,
|
onClick: (ChapterDownloadAction) -> Unit,
|
||||||
) {
|
) {
|
||||||
@ -70,6 +85,7 @@ private fun NotDownloadedIndicator(
|
|||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(IconButtonTokens.StateLayerSize)
|
.size(IconButtonTokens.StateLayerSize)
|
||||||
.commonClickable(
|
.commonClickable(
|
||||||
|
enabled = enabled,
|
||||||
onLongClick = { onClick(ChapterDownloadAction.START_NOW) },
|
onLongClick = { onClick(ChapterDownloadAction.START_NOW) },
|
||||||
onClick = { onClick(ChapterDownloadAction.START) },
|
onClick = { onClick(ChapterDownloadAction.START) },
|
||||||
)
|
)
|
||||||
@ -87,6 +103,7 @@ private fun NotDownloadedIndicator(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DownloadingIndicator(
|
private fun DownloadingIndicator(
|
||||||
|
enabled: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
downloadState: Download.State,
|
downloadState: Download.State,
|
||||||
downloadProgressProvider: () -> Int,
|
downloadProgressProvider: () -> Int,
|
||||||
@ -97,6 +114,7 @@ private fun DownloadingIndicator(
|
|||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(IconButtonTokens.StateLayerSize)
|
.size(IconButtonTokens.StateLayerSize)
|
||||||
.commonClickable(
|
.commonClickable(
|
||||||
|
enabled = enabled,
|
||||||
onLongClick = { onClick(ChapterDownloadAction.CANCEL) },
|
onLongClick = { onClick(ChapterDownloadAction.CANCEL) },
|
||||||
onClick = { isMenuExpanded = true },
|
onClick = { isMenuExpanded = true },
|
||||||
),
|
),
|
||||||
@ -158,6 +176,7 @@ private fun DownloadingIndicator(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DownloadedIndicator(
|
private fun DownloadedIndicator(
|
||||||
|
enabled: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onClick: (ChapterDownloadAction) -> Unit,
|
onClick: (ChapterDownloadAction) -> Unit,
|
||||||
) {
|
) {
|
||||||
@ -166,6 +185,7 @@ private fun DownloadedIndicator(
|
|||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(IconButtonTokens.StateLayerSize)
|
.size(IconButtonTokens.StateLayerSize)
|
||||||
.commonClickable(
|
.commonClickable(
|
||||||
|
enabled = enabled,
|
||||||
onLongClick = { onClick(ChapterDownloadAction.DELETE) },
|
onLongClick = { onClick(ChapterDownloadAction.DELETE) },
|
||||||
onClick = { isMenuExpanded = true },
|
onClick = { isMenuExpanded = true },
|
||||||
),
|
),
|
||||||
@ -191,6 +211,7 @@ private fun DownloadedIndicator(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ErrorIndicator(
|
private fun ErrorIndicator(
|
||||||
|
enabled: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onClick: (ChapterDownloadAction) -> Unit,
|
onClick: (ChapterDownloadAction) -> Unit,
|
||||||
) {
|
) {
|
||||||
@ -198,6 +219,7 @@ private fun ErrorIndicator(
|
|||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(IconButtonTokens.StateLayerSize)
|
.size(IconButtonTokens.StateLayerSize)
|
||||||
.commonClickable(
|
.commonClickable(
|
||||||
|
enabled = enabled,
|
||||||
onLongClick = { onClick(ChapterDownloadAction.START) },
|
onLongClick = { onClick(ChapterDownloadAction.START) },
|
||||||
onClick = { onClick(ChapterDownloadAction.START) },
|
onClick = { onClick(ChapterDownloadAction.START) },
|
||||||
),
|
),
|
||||||
@ -213,10 +235,12 @@ private fun ErrorIndicator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Modifier.commonClickable(
|
private fun Modifier.commonClickable(
|
||||||
|
enabled: Boolean,
|
||||||
onLongClick: () -> Unit,
|
onLongClick: () -> Unit,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) = composed {
|
) = composed {
|
||||||
this.combinedClickable(
|
this.combinedClickable(
|
||||||
|
enabled = enabled,
|
||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
role = Role.Button,
|
role = Role.Button,
|
||||||
|
@ -354,6 +354,7 @@ private fun MangaScreenSmallImpl(
|
|||||||
contentType = MangaScreenItem.CHAPTER_HEADER,
|
contentType = MangaScreenItem.CHAPTER_HEADER,
|
||||||
) {
|
) {
|
||||||
ChapterHeader(
|
ChapterHeader(
|
||||||
|
enabled = chapters.fastAll { !it.selected },
|
||||||
chapterCount = chapters.size,
|
chapterCount = chapters.size,
|
||||||
onClick = onFilterClicked,
|
onClick = onFilterClicked,
|
||||||
)
|
)
|
||||||
@ -553,6 +554,7 @@ fun MangaScreenLargeImpl(
|
|||||||
contentType = MangaScreenItem.CHAPTER_HEADER,
|
contentType = MangaScreenItem.CHAPTER_HEADER,
|
||||||
) {
|
) {
|
||||||
ChapterHeader(
|
ChapterHeader(
|
||||||
|
enabled = chapters.fastAll { !it.selected },
|
||||||
chapterCount = chapters.size,
|
chapterCount = chapters.size,
|
||||||
onClick = onFilterButtonClicked,
|
onClick = onFilterButtonClicked,
|
||||||
)
|
)
|
||||||
@ -634,6 +636,7 @@ private fun LazyListScope.sharedChapterItems(
|
|||||||
read = chapterItem.chapter.read,
|
read = chapterItem.chapter.read,
|
||||||
bookmark = chapterItem.chapter.bookmark,
|
bookmark = chapterItem.chapter.bookmark,
|
||||||
selected = chapterItem.selected,
|
selected = chapterItem.selected,
|
||||||
|
downloadIndicatorEnabled = chapters.fastAll { !it.selected },
|
||||||
downloadStateProvider = { chapterItem.downloadState },
|
downloadStateProvider = { chapterItem.downloadState },
|
||||||
downloadProgressProvider = { chapterItem.downloadProgress },
|
downloadProgressProvider = { chapterItem.downloadProgress },
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
|
@ -16,13 +16,17 @@ import eu.kanade.tachiyomi.R
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChapterHeader(
|
fun ChapterHeader(
|
||||||
|
enabled: Boolean,
|
||||||
chapterCount: Int?,
|
chapterCount: Int?,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable(onClick = onClick)
|
.clickable(
|
||||||
|
enabled = enabled,
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
.padding(horizontal = 16.dp, vertical = 4.dp),
|
.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
@ -46,6 +46,7 @@ fun MangaChapterListItem(
|
|||||||
read: Boolean,
|
read: Boolean,
|
||||||
bookmark: Boolean,
|
bookmark: Boolean,
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
|
downloadIndicatorEnabled: Boolean,
|
||||||
downloadStateProvider: () -> Download.State,
|
downloadStateProvider: () -> Download.State,
|
||||||
downloadProgressProvider: () -> Int,
|
downloadProgressProvider: () -> Int,
|
||||||
onLongClick: () -> Unit,
|
onLongClick: () -> Unit,
|
||||||
@ -129,6 +130,7 @@ fun MangaChapterListItem(
|
|||||||
// Download view
|
// Download view
|
||||||
if (onDownloadClick != null) {
|
if (onDownloadClick != null) {
|
||||||
ChapterDownloadIndicator(
|
ChapterDownloadIndicator(
|
||||||
|
enabled = downloadIndicatorEnabled,
|
||||||
modifier = Modifier.padding(start = 4.dp),
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
downloadStateProvider = downloadStateProvider,
|
downloadStateProvider = downloadStateProvider,
|
||||||
downloadProgressProvider = downloadProgressProvider,
|
downloadProgressProvider = downloadProgressProvider,
|
||||||
|
@ -135,6 +135,7 @@ fun LazyListScope.updatesUiItems(
|
|||||||
onDownloadChapter = {
|
onDownloadChapter = {
|
||||||
if (selectionMode.not()) onDownloadChapter(listOf(updatesItem), it)
|
if (selectionMode.not()) onDownloadChapter(listOf(updatesItem), it)
|
||||||
},
|
},
|
||||||
|
downloadIndicatorEnabled = selectionMode.not(),
|
||||||
downloadStateProvider = updatesItem.downloadStateProvider,
|
downloadStateProvider = updatesItem.downloadStateProvider,
|
||||||
downloadProgressProvider = updatesItem.downloadProgressProvider,
|
downloadProgressProvider = updatesItem.downloadProgressProvider,
|
||||||
)
|
)
|
||||||
@ -153,6 +154,7 @@ fun UpdatesUiItem(
|
|||||||
onClickCover: () -> Unit,
|
onClickCover: () -> Unit,
|
||||||
onDownloadChapter: (ChapterDownloadAction) -> Unit,
|
onDownloadChapter: (ChapterDownloadAction) -> Unit,
|
||||||
// Download Indicator
|
// Download Indicator
|
||||||
|
downloadIndicatorEnabled: Boolean,
|
||||||
downloadStateProvider: () -> Download.State,
|
downloadStateProvider: () -> Download.State,
|
||||||
downloadProgressProvider: () -> Int,
|
downloadProgressProvider: () -> Int,
|
||||||
) {
|
) {
|
||||||
@ -225,6 +227,7 @@ fun UpdatesUiItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChapterDownloadIndicator(
|
ChapterDownloadIndicator(
|
||||||
|
enabled = downloadIndicatorEnabled,
|
||||||
modifier = Modifier.padding(start = 4.dp),
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
downloadStateProvider = downloadStateProvider,
|
downloadStateProvider = downloadStateProvider,
|
||||||
downloadProgressProvider = downloadProgressProvider,
|
downloadProgressProvider = downloadProgressProvider,
|
||||||
|
Loading…
Reference in New Issue
Block a user