Skip to content

Commit

Permalink
CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brynbodayle committed Feb 21, 2024
1 parent c0c12cd commit 8519841
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension MeasuringViewRepresentable {
size = uiView.measuredFittingSize
}

#if swift(>=5.7) // Proxy check for being built with the iOS 15 SDK
#if swift(>=5.7.1) // Proxy check for being built with the iOS 15 SDK
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public func sizeThatFits(
_ proposal: ProposedViewSize,
Expand All @@ -90,7 +90,7 @@ extension MeasuringViewRepresentable {
{
nsView.strategy = sizing
let children = Mirror(reflecting: proposedSize).children
nsView.proposedSize = proposal.viewTypeValue
nsView.proposedSize = proposedSize.viewTypeValue
size = nsView.measuredFittingSize
}

Expand All @@ -111,7 +111,7 @@ extension MeasuringViewRepresentable {
}
#endif

#if swift(>=5.7) // Proxy check for being built with the iOS 15 SDK
#if swift(>=5.7.1) // Proxy check for being built with the iOS 15 SDK
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
extension ProposedViewSize {
/// Creates a size by replacing `nil`s with `UIView.noIntrinsicMetric`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public final class SwiftUIMeasurementContainer<Content: ViewType>: ViewType {

// The proposed size is only used by the measurement, so just re-measure.
_measuredFittingSize = nil
setNeedsUpdateConstraints()
setNeedsUpdateConstraintsForPlatform()
}
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public final class SwiftUIMeasurementContainer<Content: ViewType>: ViewType {
/// The cached `measuredFittingSize` to prevent unnecessary re-measurements.
private var _measuredFittingSize: CGSize? {
didSet {
setNeedsUpdateConstraints()
setNeedsUpdateConstraintsForPlatform()
}
}

Expand Down Expand Up @@ -278,9 +278,25 @@ public final class SwiftUIMeasurementContainer<Content: ViewType>: ViewType {
}
}

private func setNeedsUpdateConstraintsForPlatform() {
#if os(iOS) || os(tvOS)
setNeedsUpdateConstraints()
#elseif os(macOS)
needsUpdateConstraints = true
#endif
}

private func updateConstraintsForPlatformIfNeeded() {
#if os(iOS) || os(tvOS)
updateConstraintsIfNeeded()
#elseif os(macOS)
updateConstraintsForSubtreeIfNeeded()
#endif
}

/// Measures the `uiView`, storing the resulting size in `measuredIntrinsicContentSize`.
private func measureView() -> CGSize {
updateConstraintsIfNeeded()
updateConstraintsForPlatformIfNeeded()
latestMeasurementBoundsSize = bounds.size

var measuredSize: CGSize
Expand All @@ -299,7 +315,7 @@ public final class SwiftUIMeasurementContainer<Content: ViewType>: ViewType {
measuredSize.height = ViewType.noIntrinsicMetric

case .intrinsicHeightProposedOrIntrinsicWidth:
let fittingSize = content.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
let fittingSize = content.systemLayoutFittingIntrinsicSize()
measuredSize = CGSize(
width: min(fittingSize.width, proposedSize.width > 0 ? proposedSize.width : fittingSize.width),
height: fittingSize.height)
Expand Down

0 comments on commit 8519841

Please sign in to comment.