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 {
|
public protocol DuckableViewController: UIViewController {
|
||||||
var duckableDelegate: DuckableViewControllerDelegate? { get set }
|
var duckableDelegate: DuckableViewControllerDelegate? { get set }
|
||||||
|
|
||||||
|
func duckableViewControllerShouldDuck() -> Bool
|
||||||
|
|
||||||
func duckableViewControllerMayAttemptToDuck()
|
func duckableViewControllerMayAttemptToDuck()
|
||||||
|
|
||||||
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat)
|
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat)
|
||||||
|
@ -18,6 +20,7 @@ public protocol DuckableViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DuckableViewController {
|
extension DuckableViewController {
|
||||||
|
public func duckableViewControllerShouldDuck() -> Bool { true }
|
||||||
public func duckableViewControllerMayAttemptToDuck() {}
|
public func duckableViewControllerMayAttemptToDuck() {}
|
||||||
public func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {}
|
public func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {}
|
||||||
public func duckableViewControllerDidFinishAnimatingDuck() {}
|
public func duckableViewControllerDidFinishAnimatingDuck() {}
|
||||||
|
|
|
@ -135,6 +135,10 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont
|
||||||
guard case .presentingDucked(let viewController, isFirstPresentation: _) = state else {
|
guard case .presentingDucked(let viewController, isFirstPresentation: _) = state else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
guard viewController.duckableViewControllerShouldDuck() else {
|
||||||
|
viewController.sheetPresentationController!.selectedDetentIdentifier = .large
|
||||||
|
return
|
||||||
|
}
|
||||||
let placeholder = createPlaceholderForDuckedViewController(viewController)
|
let placeholder = createPlaceholderForDuckedViewController(viewController)
|
||||||
state = .ducked(viewController, placeholder: placeholder)
|
state = .ducked(viewController, placeholder: placeholder)
|
||||||
configureChildForDuckedPlaceholder()
|
configureChildForDuckedPlaceholder()
|
||||||
|
@ -235,4 +239,3 @@ extension DuckableContainerViewController: UISheetPresentationControllerDelegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue