@@ -23,11 +23,13 @@ import UIKit
2323
2424class SPStorkPresentationController : UIPresentationController , UIGestureRecognizerDelegate {
2525
26- var isSwipeToDismissEnabled : Bool = true
27- var isTapAroundToDismissEnabled : Bool = true
26+ var swipeToDismissEnabled : Bool = true
27+ var tapAroundToDismissEnabled : Bool = true
2828 var showIndicator : Bool = true
2929 var indicatorColor : UIColor = UIColor . init ( red: 202 / 255 , green: 201 / 255 , blue: 207 / 255 , alpha: 1 )
3030 var customHeight : CGFloat ? = nil
31+ var translateForDismiss : CGFloat = 240
32+
3133 var transitioningDelegate : SPStorkTransitioningDelegate ?
3234
3335 var pan : UIPanGestureRecognizer ?
@@ -84,7 +86,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
8486
8587 if self . showIndicator {
8688 self . indicatorView. color = self . indicatorColor
87- let tap = UITapGestureRecognizer . init ( target: self , action: #selector( self . handleTap ) )
89+ let tap = UITapGestureRecognizer . init ( target: self , action: #selector( self . dismissAction ) )
8890 tap. cancelsTouchesInView = false
8991 self . indicatorView. addGestureRecognizer ( tap)
9092 presentedView. addSubview ( self . indicatorView)
@@ -169,13 +171,13 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
169171 self . snapshotViewContainer. centerXAnchor. constraint ( equalTo: containerView. centerXAnchor) . isActive = true
170172 self . updateSnapshotAspectRatio ( )
171173
172- if self . isTapAroundToDismissEnabled {
173- self . tap = UITapGestureRecognizer . init ( target: self , action: #selector( self . handleTap ) )
174+ if self . tapAroundToDismissEnabled {
175+ self . tap = UITapGestureRecognizer . init ( target: self , action: #selector( self . dismissAction ) )
174176 self . tap? . cancelsTouchesInView = false
175177 self . snapshotViewContainer. addGestureRecognizer ( self . tap!)
176178 }
177179
178- if self . isSwipeToDismissEnabled {
180+ if self . swipeToDismissEnabled {
179181 self . pan = UIPanGestureRecognizer ( target: self , action: #selector( self . handlePan) )
180182 self . pan!. delegate = self
181183 self . pan!. maximumNumberOfTouches = 1
@@ -184,7 +186,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
184186 }
185187 }
186188
187- @objc func handleTap ( ) {
189+ @objc func dismissAction ( ) {
188190 self . presentedViewController. dismiss ( animated: true , completion: nil )
189191 }
190192
@@ -266,7 +268,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
266268extension SPStorkPresentationController {
267269
268270 @objc func handlePan( gestureRecognizer: UIPanGestureRecognizer ) {
269- guard gestureRecognizer. isEqual ( pan) , self . isSwipeToDismissEnabled else { return }
271+ guard gestureRecognizer. isEqual ( self . pan) , self . swipeToDismissEnabled else { return }
270272
271273 switch gestureRecognizer. state {
272274 case . began:
@@ -278,7 +280,7 @@ extension SPStorkPresentationController {
278280 gestureRecognizer. setTranslation ( CGPoint ( x: 0 , y: 0 ) , in: containerView)
279281 case . changed:
280282 self . workGester = true
281- if self . isSwipeToDismissEnabled {
283+ if self . swipeToDismissEnabled {
282284 let translation = gestureRecognizer. translation ( in: presentedView)
283285 self . updatePresentedViewForTranslation ( inVerticalDirection: translation. y)
284286 } else {
@@ -287,7 +289,7 @@ extension SPStorkPresentationController {
287289 case . ended:
288290 self . workGester = false
289291 let translation = gestureRecognizer. translation ( in: presentedView) . y
290- if translation >= 240 {
292+ if translation >= self . translateForDismiss {
291293 presentedViewController. dismiss ( animated: true , completion: nil )
292294 } else {
293295 self . indicatorView. style = . arrow
0 commit comments