ChapterDownloadIndicator: Ensure uniform hit area (#7453)

This commit is contained in:
AntsyLich 2022-07-05 08:36:59 +06:00 committed by GitHub
parent 591df8abcc
commit eef95cef33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,11 +59,14 @@ fun ChapterDownloadIndicator(
onClick(chapterDownloadAction) onClick(chapterDownloadAction)
}, },
) { ) {
val indicatorModifier = Modifier
.size(IndicatorSize)
.padding(IndicatorPadding)
if (isDownloaded) { if (isDownloaded) {
Icon( Icon(
imageVector = Icons.Default.CheckCircle, imageVector = Icons.Default.CheckCircle,
contentDescription = null, contentDescription = null,
modifier = Modifier.size(IndicatorSize), modifier = indicatorModifier,
tint = MaterialTheme.colorScheme.onSurfaceVariant, tint = MaterialTheme.colorScheme.onSurfaceVariant,
) )
DropdownMenu(expanded = isMenuExpanded, onDismissRequest = { isMenuExpanded = false }) { DropdownMenu(expanded = isMenuExpanded, onDismissRequest = { isMenuExpanded = false }) {
@ -76,9 +79,6 @@ fun ChapterDownloadIndicator(
) )
} }
} else { } else {
val progressIndicatorModifier = Modifier
.size(IndicatorSize)
.padding(IndicatorStrokeWidth)
val inactiveAlphaModifier = if (!isDownloading) Modifier.secondaryItemAlpha() else Modifier val inactiveAlphaModifier = if (!isDownloading) Modifier.secondaryItemAlpha() else Modifier
val arrowModifier = Modifier val arrowModifier = Modifier
.size(IndicatorSize - 7.dp) .size(IndicatorSize - 7.dp)
@ -91,7 +91,7 @@ fun ChapterDownloadIndicator(
if (indeterminate) { if (indeterminate) {
arrowColor = strokeColor arrowColor = strokeColor
CircularProgressIndicator( CircularProgressIndicator(
modifier = progressIndicatorModifier, modifier = indicatorModifier,
color = strokeColor, color = strokeColor,
strokeWidth = IndicatorStrokeWidth, strokeWidth = IndicatorStrokeWidth,
) )
@ -107,7 +107,7 @@ fun ChapterDownloadIndicator(
} }
CircularProgressIndicator( CircularProgressIndicator(
progress = animatedProgress, progress = animatedProgress,
modifier = progressIndicatorModifier, modifier = indicatorModifier,
color = strokeColor, color = strokeColor,
strokeWidth = IndicatorSize / 2, strokeWidth = IndicatorSize / 2,
) )
@ -116,7 +116,7 @@ fun ChapterDownloadIndicator(
arrowColor = strokeColor arrowColor = strokeColor
CircularProgressIndicator( CircularProgressIndicator(
progress = 1f, progress = 1f,
modifier = progressIndicatorModifier.then(inactiveAlphaModifier), modifier = indicatorModifier.then(inactiveAlphaModifier),
color = strokeColor, color = strokeColor,
strokeWidth = IndicatorStrokeWidth, strokeWidth = IndicatorStrokeWidth,
) )
@ -150,4 +150,6 @@ fun ChapterDownloadIndicator(
} }
private val IndicatorSize = 26.dp private val IndicatorSize = 26.dp
private val IndicatorStrokeWidth = 2.dp private val IndicatorPadding = 2.dp
// To match composable parameter name when used later
private val IndicatorStrokeWidth = IndicatorPadding