From b9f442a035c7b4d9069dac0cb3bb4bbbf22bddc1 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Fri, 3 Nov 2023 18:14:03 -0400 Subject: [PATCH 1/3] Pin hosting controller to the top of the layout margin guide to respect safe areas on top bars --- Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift index d7ab1933..e8ecb43b 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift @@ -343,7 +343,7 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie viewController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ viewController.view.leadingAnchor.constraint(equalTo: leadingAnchor), - viewController.view.topAnchor.constraint(equalTo: topAnchor), + viewController.view.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor), viewController.view.trailingAnchor.constraint(equalTo: trailingAnchor), viewController.view.bottomAnchor.constraint(equalTo: bottomAnchor), ]) From aaa303d9e92914415b2a0d25d983bb5ea16fba5a Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Tue, 7 Nov 2023 13:19:14 -0500 Subject: [PATCH 2/3] Add comments and pin to the bottom layout margins as well --- Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift index e8ecb43b..5b173436 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift @@ -343,9 +343,13 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie viewController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ viewController.view.leadingAnchor.constraint(equalTo: leadingAnchor), + // 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) From e29397afbe8ad4c8d6f43af489fd7646ed881574 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Tue, 7 Nov 2023 13:19:17 -0500 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a459bca..fbfb15c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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