Skip to content

Commit

Permalink
Don't fill the available space in AsyncImage when the painter has no …
Browse files Browse the repository at this point in the history
…intrinsic size.
  • Loading branch information
colinrtwhite committed Oct 28, 2024
1 parent 1d4b9a8 commit 3161e2d
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,21 @@ internal class ContentPainterNode(
return constraints
}

// Fill the available space if the painter has no intrinsic size.
val hasBoundedSize = constraints.hasBoundedWidth && constraints.hasBoundedHeight
// Changed from `PainterModifier`:
// The painter has no intrinsic size so we can't support scaling.
val intrinsicSize = painter.intrinsicSize
if (intrinsicSize.isUnspecified) {
if (hasBoundedSize) {
return constraints.copy(
minWidth = constraints.maxWidth,
minHeight = constraints.maxHeight,
)
} else {
return constraints
}
return constraints
}

// Changed from `PainterModifier`:
// Use the maximum space as the destination size if the constraints are bounded and at
// least one dimension is a fixed pixel value. Else, use the intrinsic size of the painter.
val dstWidth: Float
val dstHeight: Float
if (hasBoundedSize && (hasFixedWidth || hasFixedHeight)) {
if ((hasFixedWidth || hasFixedHeight) &&
(constraints.hasBoundedWidth && constraints.hasBoundedHeight)
) {
dstWidth = constraints.maxWidth.toFloat()
dstHeight = constraints.maxHeight.toFloat()
} else {
Expand Down

0 comments on commit 3161e2d

Please sign in to comment.