Upgrade peek controller to modern context menu implementation

This commit is contained in:
Ilya Laktyushin
2021-05-07 21:16:24 +04:00
parent b1e91b3c72
commit 4a465a5893
42 changed files with 728 additions and 981 deletions

View File

@@ -183,8 +183,6 @@ public enum TabBarItemContextActionType {
public let navigationBar: NavigationBar?
private(set) var toolbar: Toolbar?
private var previewingContext: Any?
public var displayNavigationBar = true
open var navigationBarRequiresEntireLayoutUpdate: Bool {
return true
@@ -612,33 +610,6 @@ public enum TabBarItemContextActionType {
}
}
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
open func registerForPreviewing(with delegate: UIViewControllerPreviewingDelegate, sourceView: UIView, theme: PeekControllerTheme, onlyNative: Bool) {
}
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
public func registerForPreviewingNonNative(with delegate: UIViewControllerPreviewingDelegate, sourceView: UIView, theme: PeekControllerTheme) {
if true || self.traitCollection.forceTouchCapability != .available {
if self.previewingContext == nil {
let previewingContext = SimulatedViewControllerPreviewing(theme: theme, delegate: delegate, sourceView: sourceView, node: self.displayNode, present: { [weak self] c, a in
self?.presentInGlobalOverlay(c, with: a)
}, customPresent: { [weak self] c, n in
return self?.customPresentPreviewingController?(c, n)
})
self.previewingContext = previewingContext
}
}
}
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
open override func unregisterForPreviewing(withContext previewing: UIViewControllerPreviewing) {
if self.previewingContext != nil {
self.previewingContext = nil
} else {
super.unregisterForPreviewing(withContext: previewing)
}
}
public final func navigationNextSibling() -> UIViewController? {
if let navigationController = self.navigationController as? NavigationController {
if let index = navigationController.viewControllers.firstIndex(where: { $0 === self }) {