From f0dd33ee4cf0a355eb9729d723ca78c80340973a Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sat, 6 May 2023 22:15:39 +0700 Subject: [PATCH] ChapterNavigator: Always show buttons and fix steps visual (#9461) --- .../presentation/reader/ChapterNavigator.kt | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt b/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt index a6b0f6f07..a4321fa2c 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/ChapterNavigator.kt @@ -64,20 +64,19 @@ fun ChapterNavigator( val backgroundColor = MaterialTheme.colorScheme .surfaceColorAtElevation(3.dp) .copy(alpha = if (isSystemInDarkTheme()) 0.9f else 0.95f) - - val isLeftEnabled = if (isRtl) enabledNext else enabledPrevious - if (isLeftEnabled) { - FilledIconButton( - onClick = if (isRtl) onNextChapter else onPreviousChapter, - colors = IconButtonDefaults.filledIconButtonColors( - containerColor = backgroundColor, - ), - ) { - Icon( - imageVector = Icons.Outlined.SkipPrevious, - contentDescription = stringResource(if (isRtl) R.string.action_next_chapter else R.string.action_previous_chapter), - ) - } + val buttonColor = IconButtonDefaults.filledIconButtonColors( + containerColor = backgroundColor, + disabledContainerColor = backgroundColor, + ) + FilledIconButton( + enabled = if (isRtl) enabledNext else enabledPrevious, + onClick = if (isRtl) onNextChapter else onPreviousChapter, + colors = buttonColor, + ) { + Icon( + imageVector = Icons.Outlined.SkipPrevious, + contentDescription = stringResource(if (isRtl) R.string.action_next_chapter else R.string.action_previous_chapter), + ) } if (totalPages > 1) { @@ -105,7 +104,7 @@ fun ChapterNavigator( .padding(horizontal = 8.dp), value = currentPage.toFloat(), valueRange = 1f..totalPages.toFloat(), - steps = totalPages, + steps = totalPages - 2, onValueChange = { onSliderValueChange(it.toInt() - 1) }, @@ -119,19 +118,15 @@ fun ChapterNavigator( Spacer(Modifier.weight(1f)) } - val isRightEnabled = if (isRtl) enabledPrevious else enabledNext - if (isRightEnabled) { - FilledIconButton( - onClick = if (isRtl) onPreviousChapter else onNextChapter, - colors = IconButtonDefaults.filledIconButtonColors( - containerColor = backgroundColor, - ), - ) { - Icon( - imageVector = Icons.Outlined.SkipNext, - contentDescription = stringResource(if (isRtl) R.string.action_previous_chapter else R.string.action_next_chapter), - ) - } + FilledIconButton( + enabled = if (isRtl) enabledPrevious else enabledNext, + onClick = if (isRtl) onPreviousChapter else onNextChapter, + colors = buttonColor, + ) { + Icon( + imageVector = Icons.Outlined.SkipNext, + contentDescription = stringResource(if (isRtl) R.string.action_previous_chapter else R.string.action_next_chapter), + ) } } }