Adaptive Layout
This commit is contained in:
@@ -145,7 +145,7 @@ private fun Placeable.PlacementScope.portrait(
|
|||||||
divider1Placeable.place(0, gridSize + spacingPx)
|
divider1Placeable.place(0, gridSize + spacingPx)
|
||||||
|
|
||||||
// Position the horizontal clues
|
// Position the horizontal clues
|
||||||
val offsetY = placeClues(
|
var offsetY = placeClues(
|
||||||
placeables = horizontalCluesPlaceables,
|
placeables = horizontalCluesPlaceables,
|
||||||
offsetX = 0,
|
offsetX = 0,
|
||||||
offsetY = gridSize + 2 * spacingPx,
|
offsetY = gridSize + 2 * spacingPx,
|
||||||
@@ -156,7 +156,7 @@ private fun Placeable.PlacementScope.portrait(
|
|||||||
divider2Placeable.place(0, offsetY + spacingPx)
|
divider2Placeable.place(0, offsetY + spacingPx)
|
||||||
|
|
||||||
// Position the vertical clues
|
// Position the vertical clues
|
||||||
placeClues(
|
offsetY = placeClues(
|
||||||
placeables = verticalCluesPlaceables,
|
placeables = verticalCluesPlaceables,
|
||||||
offsetX = 0,
|
offsetX = 0,
|
||||||
offsetY = offsetY + spacingPx + divider2Placeable.height,
|
offsetY = offsetY + spacingPx + divider2Placeable.height,
|
||||||
@@ -164,11 +164,27 @@ private fun Placeable.PlacementScope.portrait(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Position the time
|
// Position the time
|
||||||
|
val remainingSpace = constraints.maxHeight - offsetY
|
||||||
|
if (remainingSpace < timePlaceable.height) {
|
||||||
|
val scale = remainingSpace.toFloat() / timePlaceable.height.toFloat()
|
||||||
|
if (scale > 0.1f) {
|
||||||
|
timePlaceable.placeWithLayer(
|
||||||
|
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
||||||
|
y = constraints.maxHeight - timePlaceable.height
|
||||||
|
) {
|
||||||
|
scaleX = scale
|
||||||
|
scaleY = scale
|
||||||
|
translationX = (timePlaceable.width * (1 - scale)) / 2f
|
||||||
|
translationY = (timePlaceable.height * (1 - scale)) / 2f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
timePlaceable.place(
|
timePlaceable.place(
|
||||||
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
||||||
y = constraints.maxHeight - timePlaceable.height
|
y = constraints.maxHeight - timePlaceable.height
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun Placeable.PlacementScope.squarish(
|
private fun Placeable.PlacementScope.squarish(
|
||||||
constraints: Constraints,
|
constraints: Constraints,
|
||||||
@@ -297,8 +313,7 @@ private fun Placeable.PlacementScope.placeClues(
|
|||||||
placeables: List<Placeable>,
|
placeables: List<Placeable>,
|
||||||
offsetX: Int,
|
offsetX: Int,
|
||||||
offsetY: Int,
|
offsetY: Int,
|
||||||
maxWidth: Int,
|
maxWidth: Int
|
||||||
minSpacing: Int = 0
|
|
||||||
): Int {
|
): Int {
|
||||||
if (placeables.isEmpty()) return offsetY
|
if (placeables.isEmpty()) return offsetY
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user