mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Cleanup in CommonMangaItem.kt
Closes #19 Co-authored-by: Roshan Varughese <40583749+Animeboynz@users.noreply.github.com>
This commit is contained in:
parent
e57638a49c
commit
e17f70f722
1 changed files with 32 additions and 14 deletions
|
@ -35,6 +35,7 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.graphics.Shadow
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import eu.kanade.presentation.manga.components.MangaCover
|
||||
|
@ -42,15 +43,22 @@ import tachiyomi.i18n.MR
|
|||
import tachiyomi.presentation.core.components.BadgeGroup
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
import tachiyomi.presentation.core.util.selectedBackground
|
||||
import tachiyomi.domain.manga.model.MangaCover as MangaCoverModel
|
||||
|
||||
object CommonMangaItemDefaults {
|
||||
val GridHorizontalSpacer = 4.dp
|
||||
val GridVerticalSpacer = 4.dp
|
||||
|
||||
@Suppress("ConstPropertyName")
|
||||
const val BrowseFavoriteCoverAlpha = 0.34f
|
||||
}
|
||||
|
||||
private val ContinueReadingButtonSize = 28.dp
|
||||
private val ContinueReadingButtonSizeSmall = 28.dp
|
||||
private val ContinueReadingButtonSizeLarge = 32.dp
|
||||
|
||||
private val ContinueReadingButtonIconSizeSmall = 16.dp
|
||||
private val ContinueReadingButtonIconSizeLarge = 20.dp
|
||||
|
||||
private val ContinueReadingButtonGridPadding = 6.dp
|
||||
private val ContinueReadingButtonListSpacing = 8.dp
|
||||
|
||||
|
@ -62,7 +70,7 @@ private const val GridSelectedCoverAlpha = 0.76f
|
|||
*/
|
||||
@Composable
|
||||
fun MangaCompactGridItem(
|
||||
coverData: tachiyomi.domain.manga.model.MangaCover,
|
||||
coverData: MangaCoverModel,
|
||||
onClick: () -> Unit,
|
||||
onLongClick: () -> Unit,
|
||||
isSelected: Boolean = false,
|
||||
|
@ -96,10 +104,12 @@ fun MangaCompactGridItem(
|
|||
)
|
||||
} else if (onClickContinueReading != null) {
|
||||
ContinueReadingButton(
|
||||
size = ContinueReadingButtonSizeLarge,
|
||||
iconSize = ContinueReadingButtonIconSizeLarge,
|
||||
onClick = onClickContinueReading,
|
||||
modifier = Modifier
|
||||
.padding(ContinueReadingButtonGridPadding)
|
||||
.align(Alignment.BottomEnd),
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -148,11 +158,13 @@ private fun BoxScope.CoverTextOverlay(
|
|||
)
|
||||
if (onClickContinueReading != null) {
|
||||
ContinueReadingButton(
|
||||
size = ContinueReadingButtonSizeSmall,
|
||||
iconSize = ContinueReadingButtonIconSizeSmall,
|
||||
onClick = onClickContinueReading,
|
||||
modifier = Modifier.padding(
|
||||
end = ContinueReadingButtonGridPadding,
|
||||
bottom = ContinueReadingButtonGridPadding,
|
||||
),
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +175,7 @@ private fun BoxScope.CoverTextOverlay(
|
|||
*/
|
||||
@Composable
|
||||
fun MangaComfortableGridItem(
|
||||
coverData: tachiyomi.domain.manga.model.MangaCover,
|
||||
coverData: MangaCoverModel,
|
||||
title: String,
|
||||
onClick: () -> Unit,
|
||||
onLongClick: () -> Unit,
|
||||
|
@ -194,10 +206,12 @@ fun MangaComfortableGridItem(
|
|||
content = {
|
||||
if (onClickContinueReading != null) {
|
||||
ContinueReadingButton(
|
||||
size = ContinueReadingButtonSizeLarge,
|
||||
iconSize = ContinueReadingButtonIconSizeLarge,
|
||||
onClick = onClickContinueReading,
|
||||
modifier = Modifier
|
||||
.padding(ContinueReadingButtonGridPadding)
|
||||
.align(Alignment.BottomEnd),
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -309,14 +323,14 @@ private fun GridItemSelectable(
|
|||
private fun Modifier.selectedOutline(
|
||||
isSelected: Boolean,
|
||||
color: Color,
|
||||
) = this then drawBehind { if (isSelected) drawRect(color = color) }
|
||||
) = drawBehind { if (isSelected) drawRect(color = color) }
|
||||
|
||||
/**
|
||||
* Layout of list item.
|
||||
*/
|
||||
@Composable
|
||||
fun MangaListItem(
|
||||
coverData: tachiyomi.domain.manga.model.MangaCover,
|
||||
coverData: MangaCoverModel,
|
||||
title: String,
|
||||
onClick: () -> Unit,
|
||||
onLongClick: () -> Unit,
|
||||
|
@ -354,8 +368,10 @@ fun MangaListItem(
|
|||
BadgeGroup(content = badge)
|
||||
if (onClickContinueReading != null) {
|
||||
ContinueReadingButton(
|
||||
modifier = Modifier.padding(start = ContinueReadingButtonListSpacing),
|
||||
onClickContinueReading = onClickContinueReading,
|
||||
size = ContinueReadingButtonSizeSmall,
|
||||
iconSize = ContinueReadingButtonIconSizeSmall,
|
||||
onClick = onClickContinueReading,
|
||||
modifier = Modifier.padding(start = ContinueReadingButtonListSpacing)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -363,23 +379,25 @@ fun MangaListItem(
|
|||
|
||||
@Composable
|
||||
private fun ContinueReadingButton(
|
||||
size: Dp,
|
||||
iconSize: Dp,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onClickContinueReading: () -> Unit,
|
||||
) {
|
||||
Box(modifier = modifier) {
|
||||
FilledIconButton(
|
||||
onClick = onClickContinueReading,
|
||||
modifier = Modifier.size(ContinueReadingButtonSize),
|
||||
onClick = onClick,
|
||||
shape = MaterialTheme.shapes.small,
|
||||
colors = IconButtonDefaults.filledIconButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.9f),
|
||||
contentColor = contentColorFor(MaterialTheme.colorScheme.primaryContainer),
|
||||
),
|
||||
modifier = Modifier.size(size)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.PlayArrow,
|
||||
contentDescription = stringResource(MR.strings.action_resume),
|
||||
modifier = Modifier.size(16.dp),
|
||||
modifier = Modifier.size(iconSize),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue