Skip to content

Commit

Permalink
Fix OnlyPaddingValues horizontal values
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Sep 22, 2024
1 parent 9802d18 commit 229add3
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,27 @@ private class OnlyPaddingValues(
}

override fun calculateLeftPadding(layoutDirection: LayoutDirection): Dp {
if (sides.hasAny(PaddingValuesSides.Left)) {
return delegate.calculateLeftPadding(layoutDirection)
if (layoutDirection == LayoutDirection.Ltr) {
if (sides.hasAny(PaddingValuesSides.AllowLeftInLtr)) {
return delegate.calculateLeftPadding(layoutDirection)
}
} else {
if (sides.hasAny(PaddingValuesSides.AllowLeftInRtl)) {
return delegate.calculateLeftPadding(layoutDirection)
}
}
return 0.dp
}

override fun calculateRightPadding(layoutDirection: LayoutDirection): Dp {
if (sides.hasAny(PaddingValuesSides.Right)) {
return delegate.calculateRightPadding(layoutDirection)
if (layoutDirection == LayoutDirection.Ltr) {
if (sides.hasAny(PaddingValuesSides.AllowRightInLtr)) {
return delegate.calculateLeftPadding(layoutDirection)
}
} else {
if (sides.hasAny(PaddingValuesSides.AllowRightInRtl)) {
return delegate.calculateLeftPadding(layoutDirection)
}
}
return 0.dp
}
Expand Down

0 comments on commit 229add3

Please sign in to comment.