From 49c8a65f10b5369413f11f87e547652b2676ee6a Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Thu, 9 Nov 2023 20:25:02 -0500 Subject: [PATCH 1/4] Expose the configuration to ignore the safe area of EpoxySwiftUIHostingController --- Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift | 7 +++++-- Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift index 61ca7376..4b0d2a16 100644 --- a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift +++ b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift @@ -11,9 +11,11 @@ extension View { /// - dataID: An ID that uniquely identifies this item relative to other items in the /// same collection. /// - reuseBehavior: The reuse behavior of the `EpoxySwiftUIHostingView`. + /// - ignoreSafeArea: Weather or not the underlying`EpoxySwiftUIHostingController` will ignore its safe area. public func barModel( dataID: AnyHashable? = nil, - reuseBehavior: SwiftUIHostingViewReuseBehavior = .reusable) + reuseBehavior: SwiftUIHostingViewReuseBehavior = .reusable, + ignoreSafeArea: Bool = false) -> BarModel> { EpoxySwiftUIHostingView.barModel( @@ -21,7 +23,8 @@ extension View { content: .init(rootView: self, dataID: dataID), style: .init( reuseBehavior: reuseBehavior, - initialContent: .init(rootView: self, dataID: dataID))) + initialContent: .init(rootView: self, dataID: dataID), + ignoreSafeArea: ignoreSafeArea)) .linkDisplayLifecycle() } } diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift index b2ce33ad..9d429985 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift @@ -67,7 +67,7 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie epoxyContent = EpoxyHostingContent(rootView: style.initialContent.rootView) viewController = EpoxySwiftUIHostingController( rootView: .init(content: epoxyContent, environment: epoxyEnvironment), - ignoreSafeArea: true) + ignoreSafeArea: style.ignoreSafeArea) dataID = style.initialContent.dataID ?? DefaultDataID.noneProvided as AnyHashable @@ -97,13 +97,18 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie // MARK: Public public struct Style: Hashable { - public init(reuseBehavior: SwiftUIHostingViewReuseBehavior, initialContent: Content) { + public init( + reuseBehavior: SwiftUIHostingViewReuseBehavior, + initialContent: Content, + ignoreSafeArea: Bool = true) { self.reuseBehavior = reuseBehavior self.initialContent = initialContent + self.ignoreSafeArea = ignoreSafeArea } public var reuseBehavior: SwiftUIHostingViewReuseBehavior public var initialContent: Content + public var ignoreSafeArea: Bool public static func == (lhs: Style, rhs: Style) -> Bool { lhs.reuseBehavior == rhs.reuseBehavior From 0439bde82393ac047158bc8878edead044e7ab81 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Fri, 10 Nov 2023 09:31:29 -0500 Subject: [PATCH 2/4] Lint --- .../EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift index 9d429985..481a52d2 100644 --- a/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift +++ b/Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift @@ -97,18 +97,24 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie // MARK: Public public struct Style: Hashable { + + // MARK: Lifecycle + public init( reuseBehavior: SwiftUIHostingViewReuseBehavior, - initialContent: Content, - ignoreSafeArea: Bool = true) { + initialContent: Content, + ignoreSafeArea: Bool = true) + { self.reuseBehavior = reuseBehavior self.initialContent = initialContent self.ignoreSafeArea = ignoreSafeArea } + // MARK: Public + public var reuseBehavior: SwiftUIHostingViewReuseBehavior public var initialContent: Content - public var ignoreSafeArea: Bool + public var ignoreSafeArea: Bool public static func == (lhs: Style, rhs: Style) -> Bool { lhs.reuseBehavior == rhs.reuseBehavior From 5d5f37299540091be321ba4a86f575d21f7b8553 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Fri, 10 Nov 2023 09:38:38 -0500 Subject: [PATCH 3/4] Update bar model comment --- Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift index 4b0d2a16..d1e416af 100644 --- a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift +++ b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift @@ -12,10 +12,11 @@ extension View { /// same collection. /// - reuseBehavior: The reuse behavior of the `EpoxySwiftUIHostingView`. /// - ignoreSafeArea: Weather or not the underlying`EpoxySwiftUIHostingController` will ignore its safe area. + /// Only set this to `false` when installing this BarModel using `BarContainerInsetBehavior.barHeightContentInset` or `BarContainerInsetBehavior.none`. public func barModel( dataID: AnyHashable? = nil, reuseBehavior: SwiftUIHostingViewReuseBehavior = .reusable, - ignoreSafeArea: Bool = false) + ignoreSafeArea: Bool = true) -> BarModel> { EpoxySwiftUIHostingView.barModel( From e877b0573444f5c9c150609df26c05e06ffe79a2 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Date: Fri, 10 Nov 2023 11:47:16 -0500 Subject: [PATCH 4/4] Update Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift Co-authored-by: Bryn Bodayle --- Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift index d1e416af..26537e2b 100644 --- a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift +++ b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift @@ -11,7 +11,7 @@ extension View { /// - dataID: An ID that uniquely identifies this item relative to other items in the /// same collection. /// - reuseBehavior: The reuse behavior of the `EpoxySwiftUIHostingView`. - /// - ignoreSafeArea: Weather or not the underlying`EpoxySwiftUIHostingController` will ignore its safe area. + /// - ignoreSafeArea: Whether or not the underlying `EpoxySwiftUIHostingController` will ignore its safe area. /// Only set this to `false` when installing this BarModel using `BarContainerInsetBehavior.barHeightContentInset` or `BarContainerInsetBehavior.none`. public func barModel( dataID: AnyHashable? = nil,