Skip to content

Commit

Permalink
fix: use systemLayoutSizeFitting for SwiftUI sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
s2mr committed Apr 1, 2024
1 parent 353c88e commit fbe7dac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/SwiftUISupport/ComponentSwiftUISupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ private struct ComponentRepresenting<C: Component>: UIViewRepresentable {
if let height = proposal.height {
uiView.bounds.size.height = height
}
return uiView.intrinsicContentSize

if uiView.intrinsicContentSize != CGSize(width: UIView.noIntrinsicMetric, height: UIView.noIntrinsicMetric) {
return uiView.intrinsicContentSize
}

return uiView.systemLayoutSizeFitting(
proposal.replacingUnspecifiedDimensions(by: UIView.layoutFittingCompressedSize),
withHorizontalFittingPriority: .required,
verticalFittingPriority: .fittingSizeLevel
)
}
}

Expand Down

0 comments on commit fbe7dac

Please sign in to comment.