Skip to content

Commit

Permalink
Fix the centering math in Box on Android (#2406)
Browse files Browse the repository at this point in the history
The code was incorrectly not subtracting margins off before
centering.
  • Loading branch information
squarejesse authored Oct 23, 2024
1 parent 294decd commit dd96ce1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private class Measurer {

val left = when {
horizontalAlignment == CrossAxisAlignment.Center -> {
marginLeft + (frameWidth - width) / 2
marginLeft + (frameWidth - width - marginWidth) / 2
}
alignRight -> {
(boxMarginStart + frameWidth + boxMarginEnd) - marginRight - width
Expand All @@ -308,7 +308,7 @@ private class Measurer {

val top = when (verticalAlignment) {
CrossAxisAlignment.Center -> {
boxMarginTop + marginTop + (frameHeight - height) / 2
boxMarginTop + marginTop + (frameHeight - height - marginHeight) / 2
}
CrossAxisAlignment.End -> {
boxMarginTop + frameHeight - marginBottom - height
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd96ce1

Please sign in to comment.