ChapterNavigator: Always show buttons and fix steps visual (#9461)
This commit is contained in:
parent
e15b945e16
commit
f0dd33ee4c
1 changed files with 23 additions and 28 deletions
|
@ -64,21 +64,20 @@ fun ChapterNavigator(
|
||||||
val backgroundColor = MaterialTheme.colorScheme
|
val backgroundColor = MaterialTheme.colorScheme
|
||||||
.surfaceColorAtElevation(3.dp)
|
.surfaceColorAtElevation(3.dp)
|
||||||
.copy(alpha = if (isSystemInDarkTheme()) 0.9f else 0.95f)
|
.copy(alpha = if (isSystemInDarkTheme()) 0.9f else 0.95f)
|
||||||
|
val buttonColor = IconButtonDefaults.filledIconButtonColors(
|
||||||
val isLeftEnabled = if (isRtl) enabledNext else enabledPrevious
|
|
||||||
if (isLeftEnabled) {
|
|
||||||
FilledIconButton(
|
|
||||||
onClick = if (isRtl) onNextChapter else onPreviousChapter,
|
|
||||||
colors = IconButtonDefaults.filledIconButtonColors(
|
|
||||||
containerColor = backgroundColor,
|
containerColor = backgroundColor,
|
||||||
),
|
disabledContainerColor = backgroundColor,
|
||||||
|
)
|
||||||
|
FilledIconButton(
|
||||||
|
enabled = if (isRtl) enabledNext else enabledPrevious,
|
||||||
|
onClick = if (isRtl) onNextChapter else onPreviousChapter,
|
||||||
|
colors = buttonColor,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.SkipPrevious,
|
imageVector = Icons.Outlined.SkipPrevious,
|
||||||
contentDescription = stringResource(if (isRtl) R.string.action_next_chapter else R.string.action_previous_chapter),
|
contentDescription = stringResource(if (isRtl) R.string.action_next_chapter else R.string.action_previous_chapter),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (totalPages > 1) {
|
if (totalPages > 1) {
|
||||||
CompositionLocalProvider(LocalLayoutDirection provides layoutDirection) {
|
CompositionLocalProvider(LocalLayoutDirection provides layoutDirection) {
|
||||||
|
@ -105,7 +104,7 @@ fun ChapterNavigator(
|
||||||
.padding(horizontal = 8.dp),
|
.padding(horizontal = 8.dp),
|
||||||
value = currentPage.toFloat(),
|
value = currentPage.toFloat(),
|
||||||
valueRange = 1f..totalPages.toFloat(),
|
valueRange = 1f..totalPages.toFloat(),
|
||||||
steps = totalPages,
|
steps = totalPages - 2,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
onSliderValueChange(it.toInt() - 1)
|
onSliderValueChange(it.toInt() - 1)
|
||||||
},
|
},
|
||||||
|
@ -119,13 +118,10 @@ fun ChapterNavigator(
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
}
|
}
|
||||||
|
|
||||||
val isRightEnabled = if (isRtl) enabledPrevious else enabledNext
|
|
||||||
if (isRightEnabled) {
|
|
||||||
FilledIconButton(
|
FilledIconButton(
|
||||||
|
enabled = if (isRtl) enabledPrevious else enabledNext,
|
||||||
onClick = if (isRtl) onPreviousChapter else onNextChapter,
|
onClick = if (isRtl) onPreviousChapter else onNextChapter,
|
||||||
colors = IconButtonDefaults.filledIconButtonColors(
|
colors = buttonColor,
|
||||||
containerColor = backgroundColor,
|
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.SkipNext,
|
imageVector = Icons.Outlined.SkipNext,
|
||||||
|
@ -134,5 +130,4 @@ fun ChapterNavigator(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue