diff --git a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift index 61ca7376..26537e2b 100644 --- a/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift +++ b/Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift @@ -11,9 +11,12 @@ 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: 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, - reuseBehavior: SwiftUIHostingViewReuseBehavior = .reusable) + reuseBehavior: SwiftUIHostingViewReuseBehavior = .reusable, + ignoreSafeArea: Bool = true) -> BarModel> { EpoxySwiftUIHostingView.barModel( @@ -21,7 +24,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..481a52d2 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,24 @@ public final class EpoxySwiftUIHostingView: UIView, EpoxyableVie // MARK: Public public struct Style: Hashable { - public init(reuseBehavior: SwiftUIHostingViewReuseBehavior, initialContent: Content) { + + // MARK: Lifecycle + + public init( + reuseBehavior: SwiftUIHostingViewReuseBehavior, + 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 static func == (lhs: Style, rhs: Style) -> Bool { lhs.reuseBehavior == rhs.reuseBehavior