forked from shadowfacts/Tusker
Let duckable VCs prevent ducking
This commit is contained in:
parent
a20e8b2f48
commit
2febb37a8e
|
@ -10,6 +10,8 @@ import UIKit
|
|||
public protocol DuckableViewController: UIViewController {
|
||||
var duckableDelegate: DuckableViewControllerDelegate? { get set }
|
||||
|
||||
func duckableViewControllerShouldDuck() -> Bool
|
||||
|
||||
func duckableViewControllerMayAttemptToDuck()
|
||||
|
||||
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat)
|
||||
|
@ -18,6 +20,7 @@ public protocol DuckableViewController: UIViewController {
|
|||
}
|
||||
|
||||
extension DuckableViewController {
|
||||
public func duckableViewControllerShouldDuck() -> Bool { true }
|
||||
public func duckableViewControllerMayAttemptToDuck() {}
|
||||
public func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {}
|
||||
public func duckableViewControllerDidFinishAnimatingDuck() {}
|
||||
|
|
|
@ -135,6 +135,10 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont
|
|||
guard case .presentingDucked(let viewController, isFirstPresentation: _) = state else {
|
||||
return
|
||||
}
|
||||
guard viewController.duckableViewControllerShouldDuck() else {
|
||||
viewController.sheetPresentationController!.selectedDetentIdentifier = .large
|
||||
return
|
||||
}
|
||||
let placeholder = createPlaceholderForDuckedViewController(viewController)
|
||||
state = .ducked(viewController, placeholder: placeholder)
|
||||
configureChildForDuckedPlaceholder()
|
||||
|
@ -235,4 +239,3 @@ extension DuckableContainerViewController: UISheetPresentationControllerDelegate
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue