|
@@ -12,10 +12,17 @@ import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
+import androidx.compose.material.icons.Icons
|
|
|
+import androidx.compose.material.icons.filled.PlayArrow
|
|
|
+import androidx.compose.material3.FilledIconButton
|
|
|
+import androidx.compose.material3.Icon
|
|
|
+import androidx.compose.material3.IconButtonDefaults
|
|
|
import androidx.compose.material3.LocalContentColor
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
|
+import androidx.compose.material3.contentColorFor
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
|
import androidx.compose.ui.Alignment
|
|
@@ -41,6 +48,7 @@ object CommonMangaItemDefaults {
|
|
|
const val BrowseFavoriteCoverAlpha = 0.34f
|
|
|
}
|
|
|
|
|
|
+private val ContinueReadingButtonSize = 38.dp
|
|
|
private const val GridSelectedCoverAlpha = 0.76f
|
|
|
|
|
|
/**
|
|
@@ -55,8 +63,10 @@ fun MangaCompactGridItem(
|
|
|
coverAlpha: Float = 1f,
|
|
|
coverBadgeStart: (@Composable RowScope.() -> Unit)? = null,
|
|
|
coverBadgeEnd: (@Composable RowScope.() -> Unit)? = null,
|
|
|
+ showContinueReadingButton: Boolean = false,
|
|
|
onLongClick: () -> Unit,
|
|
|
onClick: () -> Unit,
|
|
|
+ onClickContinueReading: (() -> Unit)? = null,
|
|
|
) {
|
|
|
GridItemSelectable(
|
|
|
isSelected = isSelected,
|
|
@@ -76,7 +86,12 @@ fun MangaCompactGridItem(
|
|
|
badgesEnd = coverBadgeEnd,
|
|
|
content = {
|
|
|
if (title != null) {
|
|
|
- CoverTextOverlay(title = title)
|
|
|
+ CoverTextOverlay(title = title, showContinueReadingButton)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ continueReadingButton = {
|
|
|
+ if (showContinueReadingButton && onClickContinueReading != null) {
|
|
|
+ ContinueReadingButton(onClickContinueReading)
|
|
|
}
|
|
|
},
|
|
|
)
|
|
@@ -87,7 +102,10 @@ fun MangaCompactGridItem(
|
|
|
* Title overlay for [MangaCompactGridItem]
|
|
|
*/
|
|
|
@Composable
|
|
|
-private fun BoxScope.CoverTextOverlay(title: String) {
|
|
|
+private fun BoxScope.CoverTextOverlay(
|
|
|
+ title: String,
|
|
|
+ showContinueReadingButton: Boolean = false,
|
|
|
+) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.clip(RoundedCornerShape(bottomStart = 4.dp, bottomEnd = 4.dp))
|
|
@@ -101,9 +119,10 @@ private fun BoxScope.CoverTextOverlay(title: String) {
|
|
|
.fillMaxWidth()
|
|
|
.align(Alignment.BottomCenter),
|
|
|
)
|
|
|
+ val endPadding = if (showContinueReadingButton) ContinueReadingButtonSize else 8.dp
|
|
|
GridItemTitle(
|
|
|
modifier = Modifier
|
|
|
- .padding(8.dp)
|
|
|
+ .padding(start = 8.dp, top = 8.dp, end = endPadding, bottom = 8.dp)
|
|
|
.align(Alignment.BottomStart),
|
|
|
title = title,
|
|
|
style = MaterialTheme.typography.titleSmall.copy(
|
|
@@ -127,8 +146,10 @@ fun MangaComfortableGridItem(
|
|
|
coverAlpha: Float = 1f,
|
|
|
coverBadgeStart: (@Composable RowScope.() -> Unit)? = null,
|
|
|
coverBadgeEnd: (@Composable RowScope.() -> Unit)? = null,
|
|
|
+ showContinueReadingButton: Boolean = false,
|
|
|
onLongClick: () -> Unit,
|
|
|
onClick: () -> Unit,
|
|
|
+ onClickContinueReading: (() -> Unit)? = null,
|
|
|
) {
|
|
|
GridItemSelectable(
|
|
|
isSelected = isSelected,
|
|
@@ -147,6 +168,11 @@ fun MangaComfortableGridItem(
|
|
|
},
|
|
|
badgesStart = coverBadgeStart,
|
|
|
badgesEnd = coverBadgeEnd,
|
|
|
+ continueReadingButton = {
|
|
|
+ if (showContinueReadingButton && onClickContinueReading != null) {
|
|
|
+ ContinueReadingButton(onClickContinueReading)
|
|
|
+ }
|
|
|
+ },
|
|
|
)
|
|
|
GridItemTitle(
|
|
|
modifier = Modifier.padding(4.dp),
|
|
@@ -166,6 +192,7 @@ private fun MangaGridCover(
|
|
|
cover: @Composable BoxScope.() -> Unit = {},
|
|
|
badgesStart: (@Composable RowScope.() -> Unit)? = null,
|
|
|
badgesEnd: (@Composable RowScope.() -> Unit)? = null,
|
|
|
+ continueReadingButton: (@Composable BoxScope.() -> Unit)? = null,
|
|
|
content: @Composable (BoxScope.() -> Unit)? = null,
|
|
|
) {
|
|
|
Box(
|
|
@@ -192,6 +219,7 @@ private fun MangaGridCover(
|
|
|
content = badgesEnd,
|
|
|
)
|
|
|
}
|
|
|
+ continueReadingButton?.invoke(this)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -283,8 +311,10 @@ fun MangaListItem(
|
|
|
coverData: eu.kanade.domain.manga.model.MangaCover,
|
|
|
coverAlpha: Float = 1f,
|
|
|
badge: @Composable RowScope.() -> Unit,
|
|
|
+ showContinueReadingButton: Boolean = false,
|
|
|
onLongClick: () -> Unit,
|
|
|
onClick: () -> Unit,
|
|
|
+ onClickContinueReading: (() -> Unit)? = null,
|
|
|
) {
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
@@ -313,5 +343,37 @@ fun MangaListItem(
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
)
|
|
|
BadgeGroup(content = badge)
|
|
|
+ if (showContinueReadingButton && onClickContinueReading != null) {
|
|
|
+ Box {
|
|
|
+ ContinueReadingButton(onClickContinueReading)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+private fun BoxScope.ContinueReadingButton(
|
|
|
+ onClickContinueReading: () -> Unit,
|
|
|
+) {
|
|
|
+ FilledIconButton(
|
|
|
+ onClick = {
|
|
|
+ onClickContinueReading()
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .size(ContinueReadingButtonSize)
|
|
|
+ .padding(3.dp)
|
|
|
+ .align(Alignment.BottomEnd),
|
|
|
+ shape = MaterialTheme.shapes.small,
|
|
|
+ colors = IconButtonDefaults.filledIconButtonColors(
|
|
|
+ containerColor = MaterialTheme.colorScheme.primaryContainer,
|
|
|
+ contentColor = contentColorFor(MaterialTheme.colorScheme.primaryContainer),
|
|
|
+ ),
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ imageVector = Icons.Filled.PlayArrow,
|
|
|
+ contentDescription = "",
|
|
|
+ modifier = Modifier
|
|
|
+ .size(15.dp),
|
|
|
+ )
|
|
|
}
|
|
|
}
|