-
-
Save Mercandj/5595ab5d9c71e8e9dda60e020710b9bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun Constraints.findSize(): IntSize { | |
val matchWidth = when (aspectRatioReference) { | |
AspectRatioReference.PARENT_WIDTH -> true | |
AspectRatioReference.PARENT_HEIGHT -> false | |
AspectRatioReference.MIN_PARENT_WIDTH_PARENT_HEIGHT -> maxWidth < maxHeight | |
AspectRatioReference.MAX_PARENT_WIDTH_PARENT_HEIGHT -> maxWidth > maxHeight | |
} | |
return if (matchWidth) { | |
IntSize(maxWidth, (maxWidth * aspectRatioHeight / aspectRatioWidth).roundToInt()) | |
} else { | |
IntSize((maxHeight * aspectRatioWidth / aspectRatioHeight).roundToInt(), maxHeight) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment