Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose configuration to ignore EpoxySwiftUIHostingController safe area #161

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Sources/EpoxyBars/BarModel/SwiftUI.View+BarModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ 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<Self>>
{
EpoxySwiftUIHostingView<Self>.barModel(
dataID: dataID,
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()
}
}
15 changes: 13 additions & 2 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: true)
ignoreSafeArea: style.ignoreSafeArea)

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

Expand Down Expand Up @@ -97,13 +97,24 @@ public final class EpoxySwiftUIHostingView<RootView: View>: 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
Expand Down
Loading