Skip to content

Commit

Permalink
Fix dynamic content
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolONEOfficial committed Sep 20, 2022
1 parent ff3f8fc commit 1f9dc06
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions Sources/NativePartialSheet/NativePartialSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,8 @@ public class NativePartialSheetController<Content>: UIHostingController<Content>
}
}

extension UISheetPresentationController.Detent {
var myIdentifier: Identifier {
if #available(iOS 16.0, *) {
return self.identifier
} else {
let test = value(forKey: "identifier")
debugPrint("ffdf")
return test as! Identifier
}
}
}

public struct NativePartialSheet<Content>: Preferences, UIViewControllerRepresentable where Content : View {
private let content: Content
private let content: () -> Content
let detents: [Detent]
let preferredCornerRadius: CGFloat?
let prefersGrabberVisible: Bool
Expand All @@ -110,9 +98,9 @@ public struct NativePartialSheet<Content>: Preferences, UIViewControllerRepresen
widthFollowsPreferredContentSizeWhenEdgeAttached: Bool = false,
largestUndimmedDetent: Detent? = nil,
selectedDetent: Binding<Detent?> = .init(get: { nil }, set: { _ in }),
@ViewBuilder content: () -> Content
@ViewBuilder content: @escaping () -> Content
) {
self.content = content()
self.content = content
self.detents = detents
self.preferredCornerRadius = preferredCornerRadius
self.prefersGrabberVisible = prefersGrabberVisible
Expand All @@ -124,7 +112,7 @@ public struct NativePartialSheet<Content>: Preferences, UIViewControllerRepresen
}

public func makeUIViewController(context: Context) -> NativePartialSheetController<Content> {
let viewController = NativePartialSheetController(rootView: content)
let viewController = NativePartialSheetController(rootView: content())
viewController.prefs = self
return viewController
}
Expand All @@ -136,6 +124,6 @@ public struct NativePartialSheet<Content>: Preferences, UIViewControllerRepresen
presentation.selectedDetentIdentifier = selectedDetent.wrappedValue?.id
}
}

viewController.rootView = content()
}
}

0 comments on commit 1f9dc06

Please sign in to comment.