Add allowTapToDismiss to PanModalPresentable (#58)
This commit is contained in:
parent
af264ebb0d
commit
5c1d8c49a7
|
|
@ -111,7 +111,9 @@ public class PanModalPresentationController: UIPresentationController {
|
|||
view = DimmedView()
|
||||
}
|
||||
view.didTap = { [weak self] _ in
|
||||
self?.dismissPresentedViewController()
|
||||
if self?.presentable?.allowsTapToDismiss == true {
|
||||
self?.dismissPresentedViewController()
|
||||
}
|
||||
}
|
||||
return view
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ public extension PanModalPresentable where Self: UIViewController {
|
|||
return true
|
||||
}
|
||||
|
||||
var allowsTapToDismiss: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var isUserInteractionEnabled: Bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,6 +127,13 @@ public protocol PanModalPresentable: AnyObject {
|
|||
*/
|
||||
var allowsDragToDismiss: Bool { get }
|
||||
|
||||
/**
|
||||
A flag to determine if dismissal should be initiated when tapping on the dimmed background view.
|
||||
|
||||
Default value is true.
|
||||
*/
|
||||
var allowsTapToDismiss: Bool { get }
|
||||
|
||||
/**
|
||||
A flag to toggle user interactions on the container view.
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class PanModalTests: XCTestCase {
|
|||
XCTAssertEqual(vc.anchorModalToLongForm, true)
|
||||
XCTAssertEqual(vc.allowsExtendedPanScrolling, false)
|
||||
XCTAssertEqual(vc.allowsDragToDismiss, true)
|
||||
XCTAssertEqual(vc.allowsTapToDismiss, true)
|
||||
XCTAssertEqual(vc.isUserInteractionEnabled, true)
|
||||
XCTAssertEqual(vc.isHapticFeedbackEnabled, true)
|
||||
XCTAssertEqual(vc.shouldRoundTopCorners, false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue