Improve Direction enum

This commit is contained in:
Syer10
2022-12-31 14:17:54 -05:00
parent c06dab167a
commit 7ed64bd4b6
5 changed files with 14 additions and 11 deletions

View File

@@ -471,7 +471,7 @@ fun ReaderLayout(
currentPageOffset = currentPageOffset,
loadingModifier = loadingModifier,
pageContentScale = if (fitSize) {
if (direction == Direction.Up || direction == Direction.Down) {
if (direction.isVertical) {
ContentScale.FillWidth
} else {
ContentScale.FillHeight

View File

@@ -110,9 +110,9 @@ fun ContinuousReader(
}
val imageModifier = if (maxSize != 0) {
when (direction) {
Direction.Up, Direction.Down -> Modifier.width(maxSize.dp)
Direction.Left, Direction.Right -> Modifier.height(maxSize.dp)
when (direction.isVertical) {
true -> Modifier.width(maxSize.dp)
false -> Modifier.height(maxSize.dp)
}
} else {
Modifier
@@ -125,8 +125,8 @@ fun ContinuousReader(
}
fun retry(index: Int) { pages.find { it is ReaderPage && it.index == index }?.let { retry(it as ReaderPage) } }
when (direction) {
Direction.Down, Direction.Up -> {
when (direction.isVertical) {
true -> {
LazyColumn(
state = state,
reverseLayout = direction == Direction.Up,
@@ -151,7 +151,7 @@ fun ContinuousReader(
reverseLayout = direction == Direction.Up
)
}
Direction.Left, Direction.Right -> {
false -> {
LazyRow(
state = state,
reverseLayout = direction == Direction.Left,

View File

@@ -81,7 +81,7 @@ fun PagerReader(
val modifier = parentModifier then Modifier.fillMaxSize()
fun retry(index: Int) { pages.find { it is ReaderPage && it.index == index }?.let { retry(it as ReaderPage) } }
if (direction == Direction.Down || direction == Direction.Up) {
if (direction.isVertical) {
VerticalPager(
count = pages.size,
state = state,

View File

@@ -242,7 +242,7 @@ fun SettingsReaderScreenContent(
stringResource(MR.strings.page_padding)
)
val direction by it.direction.collectAsState()
val (title, subtitle) = if (direction == Direction.Up || direction == Direction.Down) {
val (title, subtitle) = if (direction.isVertical) {
stringResource(MR.strings.force_fit_width) to stringResource(MR.strings.force_fit_width_sub)
} else {
stringResource(MR.strings.force_fit_height) to stringResource(MR.strings.force_fit_height_sub)
@@ -253,7 +253,7 @@ fun SettingsReaderScreenContent(
subtitle
)
val maxSize by it.maxSize.collectAsState()
val (maxSizeTitle, maxSizeSubtitle) = if (direction == Direction.Up || direction == Direction.Down) {
val (maxSizeTitle, maxSizeSubtitle) = if (direction.isVertical) {
stringResource(MR.strings.max_width) to stringResource(
MR.strings.max_width_sub,
maxSize