Skip to content

Commit

Permalink
Pin hosting controller to the top of the layout margin guide (#157)
Browse files Browse the repository at this point in the history
* Pin hosting controller to the top of the layout margin guide to respect safe areas on top bars

* Add comments and pin to the bottom layout margins as well

* Update CHANGELOG.md

---------

Co-authored-by: Miguel Jimenez <[email protected]>
  • Loading branch information
miguel-jimenez-0529 and Miguel Jimenez authored Nov 7, 2023
1 parent eeb182b commit ec2f2d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
approach to resolve an issue that could cause collection view cells to layout with
unexpected dimensions
- Made new layout-based SwiftUI cell rendering option the default.
- Pin `EpoxySwiftUIHostingView` content to `layoutMarginsGuide` to ensure content respects the safe area
when installed in a `TopBarContainer` or `BottomBarContainer`.

## [0.10.0](https://github.com/airbnb/epoxy-ios/compare/0.9.0...0.10.0) - 2023-06-29

Expand Down
8 changes: 6 additions & 2 deletions Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,13 @@ public final class EpoxySwiftUIHostingView<RootView: View>: UIView, EpoxyableVie
viewController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
viewController.view.leadingAnchor.constraint(equalTo: leadingAnchor),
viewController.view.topAnchor.constraint(equalTo: topAnchor),
// Pining the hosting view controller to layoutMarginsGuide ensures the content respects the top safe area
// when installed inside a `TopBarContainer`
viewController.view.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
viewController.view.trailingAnchor.constraint(equalTo: trailingAnchor),
viewController.view.bottomAnchor.constraint(equalTo: bottomAnchor),
// Pining the hosting view controller to layoutMarginsGuide ensures the content respects the bottom safe area
// when installed inside a `BottomBarContainer`
viewController.view.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor),
])

viewController.didMove(toParent: parent)
Expand Down

0 comments on commit ec2f2d8

Please sign in to comment.