Compare commits

..

1 Commits

Author SHA1 Message Date
Ivan Vorobei ee5f9ee9de Update to 1.7.4
Add `dismissWithConfirmation` method for custom buttons.
2019-07-11 01:35:56 +03:00
7 changed files with 31 additions and 15 deletions
@@ -35,7 +35,7 @@ public enum SPStorkController {
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.4 {
if !scrollView.isTracking && !scrollView.isDragging {
presentationController.dismissWithConfirmation(prepare: nil, completion: {
self.dismissWithConfirmation(controller: controller, completion: {
presentationController.storkDelegate?.didDismissStorkBySwipe?()
})
return
@@ -58,6 +58,14 @@ public enum SPStorkController {
}
}
static public func dismissWithConfirmation(controller: UIViewController, completion: (()->())?) {
if let controller = self.presentationController(for: controller) {
controller.dismissWithConfirmation(prepare: nil, completion: {
print("Custom completion for confirmation. Confirmation is optional.")
})
}
}
static public var topScrollIndicatorInset: CGFloat {
return 6
}
@@ -49,11 +49,7 @@ class ModalTableViewController: UIViewController {
}
@objc func dismissAction() {
if let storkPresentationController = self.presentationController as? SPStorkPresentationController {
storkPresentationController.dismissWithConfirmation(prepare: nil, completion: {
print("Custom completion for confirmation. Confirmation is optional.")
})
}
SPStorkController.dismissWithConfirmation(controller: self, completion: nil)
}
}
@@ -20,11 +20,7 @@ class ModalViewController: UIViewController {
}
@objc func dismissAction() {
if let storkPresentationController = self.presentationController as? SPStorkPresentationController {
storkPresentationController.dismissWithConfirmation(prepare: nil, completion: {
print("Custom completion for confirmation. Confirmation is optional.")
})
}
SPStorkController.dismissWithConfirmation(controller: self, completion: nil)
}
override func viewWillAppear(_ animated: Bool) {
+10 -2
View File
@@ -277,7 +277,7 @@ Please, also use `SPStorkController.scrollViewDidScroll` function in scroll dele
### Confirm
For confirm closing by swipe, use `SPStorkControllerConfirmDelegate`. Implenet protocol:
For confirm closing by swipe, tap around, close button and indicator use `SPStorkControllerConfirmDelegate`. Implenet protocol:
```swift
@objc public protocol SPStorkControllerConfirmDelegate: class {
@@ -288,7 +288,15 @@ For confirm closing by swipe, use `SPStorkControllerConfirmDelegate`. Implenet p
}
```
and set `confirmDelegate` property to object, which protocol impleneted. Function `confirm` call if `needConfirm` set to `true` and controller try closing by swipe. Pass `isConfirmed` with result. Best options use `UIAlertController` with `.actionSheet` style for confirmation.
and set `confirmDelegate` property to object, which protocol impleneted. Function `confirm` call if `needConfirm` return true. Pass `isConfirmed` with result. Best options use `UIAlertController` with `.actionSheet` style for confirmation.
If you use custom buttons, in the target use this code:
```swift
SPStorkController.dismissWithConfirmation(controller: self, completion: nil)
```
It call `confirm` func and check result of confirmation. See example project for more details.
### Delegate
+1 -1
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SPStorkController"
s.version = "1.7.2"
s.version = "1.7.4"
s.summary = "Very similar to the controllers displayed in Apple Music, Podcasts and Mail Apple's applications."
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
@@ -35,7 +35,7 @@ public enum SPStorkController {
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.4 {
if !scrollView.isTracking && !scrollView.isDragging {
presentationController.dismissWithConfirmation(prepare: nil, completion: {
self.dismissWithConfirmation(controller: controller, completion: {
presentationController.storkDelegate?.didDismissStorkBySwipe?()
})
return
@@ -58,6 +58,14 @@ public enum SPStorkController {
}
}
static public func dismissWithConfirmation(controller: UIViewController, completion: (()->())?) {
if let controller = self.presentationController(for: controller) {
controller.dismissWithConfirmation(prepare: nil, completion: {
print("Custom completion for confirmation. Confirmation is optional.")
})
}
}
static public var topScrollIndicatorInset: CGFloat {
return 6
}