Skip to content

Commit

Permalink
Revert "Expose configuration to ignore EpoxySwiftUIHostingController …
Browse files Browse the repository at this point in the history
…safe area" (#165)

* Revert "Expose configuration to ignore EpoxySwiftUIHostingController safe are…"

This reverts commit e46fab4.

* Remove old comment
  • Loading branch information
bryankeller committed Mar 15, 2024
1 parent 06d9405 commit e25f291
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
8 changes: 2 additions & 6 deletions Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ 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,
ignoreSafeArea: Bool = true)
reuseBehavior: SwiftUIHostingViewReuseBehavior = .reusable)
-> BarModel<EpoxySwiftUIHostingView<Self>>
{
EpoxySwiftUIHostingView<Self>.barModel(
dataID: dataID,
content: .init(rootView: self, dataID: dataID),
style: .init(
reuseBehavior: reuseBehavior,
initialContent: .init(rootView: self, dataID: dataID),
ignoreSafeArea: ignoreSafeArea))
initialContent: .init(rootView: self, dataID: dataID)))
.linkDisplayLifecycle()
}
}
19 changes: 2 additions & 17 deletions Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final class EpoxySwiftUIHostingView<RootView: View>: UIView, EpoxyableVie
epoxyContent = EpoxyHostingContent(rootView: style.initialContent.rootView)
viewController = EpoxySwiftUIHostingController(
rootView: .init(content: epoxyContent, environment: epoxyEnvironment),
ignoreSafeArea: style.ignoreSafeArea)
ignoreSafeArea: true)

dataID = style.initialContent.dataID ?? DefaultDataID.noneProvided as AnyHashable

Expand Down Expand Up @@ -97,24 +97,13 @@ public final class EpoxySwiftUIHostingView<RootView: View>: UIView, EpoxyableVie
// MARK: Public

public struct Style: Hashable {

// MARK: Lifecycle

public init(
reuseBehavior: SwiftUIHostingViewReuseBehavior,
initialContent: Content,
ignoreSafeArea: Bool = true)
{
public init(reuseBehavior: SwiftUIHostingViewReuseBehavior, initialContent: Content) {
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
Expand Down Expand Up @@ -354,12 +343,8 @@ public final class EpoxySwiftUIHostingView<RootView: View>: 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: topAnchor),
viewController.view.trailingAnchor.constraint(equalTo: trailingAnchor),
// 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: bottomAnchor),
])

Expand Down

0 comments on commit e25f291

Please sign in to comment.