Clean up library download chapters logic

We can probably clean up the same logic in the manga controller at some point too, but that stuff's messy.
Also fixes the spacing issue that the new icon introduced.

(cherry picked from commit 33e90d6449)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt
This commit is contained in:
arkon
2022-10-30 22:56:07 -04:00
committed by Jobobby04
parent 35bd6233d9
commit b2565c7f8b
12 changed files with 174 additions and 181 deletions
@@ -9,7 +9,6 @@ import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
@@ -179,6 +178,7 @@ private fun RowScope.Button(
toConfirm: Boolean,
onLongClick: () -> Unit,
onClick: () -> Unit,
content: (@Composable () -> Unit)? = null,
) {
val animatedWeight by animateFloatAsState(if (toConfirm) 2f else 1f)
Column(
@@ -210,6 +210,7 @@ private fun RowScope.Button(
style = MaterialTheme.typography.labelSmall,
)
}
content?.invoke()
}
}
@@ -272,15 +273,14 @@ fun LibraryBottomActionMenu(
)
}
if (onDownloadClicked != null) {
Box {
var downloadExpanded by remember { mutableStateOf(false) }
this@Row.Button(
title = stringResource(R.string.action_download),
icon = Icons.Outlined.Download,
toConfirm = confirm[3],
onLongClick = { onLongClickItem(3) },
onClick = { downloadExpanded = !downloadExpanded },
)
var downloadExpanded by remember { mutableStateOf(false) }
Button(
title = stringResource(R.string.action_download),
icon = Icons.Outlined.Download,
toConfirm = confirm[3],
onLongClick = { onLongClickItem(3) },
onClick = { downloadExpanded = !downloadExpanded },
) {
val onDismissRequest = { downloadExpanded = false }
DownloadDropdownMenu(
expanded = downloadExpanded,
@@ -72,7 +72,7 @@ fun LibraryComfortableGrid(
)
},
// SY -->
buttonBottom = if (showStartReadingButton) {
buttonBottom = if (showStartReadingButton && libraryItem.unreadCount > 0) {
{ StartReadingButton(onOpenReader = { onOpenReader(libraryItem.libraryManga) }) }
} else {
null
@@ -73,12 +73,12 @@ fun LibraryCompactGrid(
)
},
// SY -->
buttonTop = if (showStartReadingButton && showTitle) {
buttonTop = if (showStartReadingButton && showTitle && libraryItem.unreadCount > 0) {
{ StartReadingButton(onOpenReader = { onOpenReader(libraryItem.libraryManga) }) }
} else {
null
},
buttonBottom = if (showStartReadingButton && !showTitle) {
buttonBottom = if (showStartReadingButton && !showTitle && libraryItem.unreadCount > 0) {
{ StartReadingButton(onOpenReader = { onOpenReader(libraryItem.libraryManga) }) }
} else {
null