Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83330bb509 | |||
| c4da6ff27e | |||
| 686bbd749b |
@@ -7,6 +7,13 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
F40DB702222A9202004E1CCB /* SPStorkViewControllerExtenshion.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB6FB222A9202004E1CCB /* SPStorkViewControllerExtenshion.swift */; };
|
||||
F40DB703222A9202004E1CCB /* SPStorkTransitioningDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB6FC222A9202004E1CCB /* SPStorkTransitioningDelegate.swift */; };
|
||||
F40DB704222A9202004E1CCB /* SPStorkPresentingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB6FD222A9202004E1CCB /* SPStorkPresentingAnimationController.swift */; };
|
||||
F40DB705222A9202004E1CCB /* SPStorkPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB6FE222A9202004E1CCB /* SPStorkPresentationController.swift */; };
|
||||
F40DB706222A9202004E1CCB /* SPStorkController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB6FF222A9202004E1CCB /* SPStorkController.swift */; };
|
||||
F40DB707222A9202004E1CCB /* SPStorkIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB700222A9202004E1CCB /* SPStorkIndicatorView.swift */; };
|
||||
F40DB708222A9202004E1CCB /* SPStorkDismissingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40DB701222A9202004E1CCB /* SPStorkDismissingAnimationController.swift */; };
|
||||
F445CA8721AED92600184254 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F445CA8621AED92600184254 /* AppDelegate.swift */; };
|
||||
F445CA8921AED92600184254 /* Controller.swift in Sources */ = {isa = PBXBuildFile; fileRef = F445CA8821AED92600184254 /* Controller.swift */; };
|
||||
F445CA8E21AED92700184254 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F445CA8D21AED92700184254 /* Assets.xcassets */; };
|
||||
@@ -131,16 +138,16 @@
|
||||
F455279E221C009E00F40446 /* SPShare.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4552721221C009D00F40446 /* SPShare.swift */; };
|
||||
F459D75B21C3AB9A00798524 /* ModalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F459D75A21C3AB9A00798524 /* ModalViewController.swift */; };
|
||||
F459D75D21C3ABBD00798524 /* ModalTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F459D75C21C3ABBD00798524 /* ModalTableViewController.swift */; };
|
||||
F4A9E9D4221C6DBA0031492C /* SPStorkViewControllerExtenshion.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9CD221C6DBA0031492C /* SPStorkViewControllerExtenshion.swift */; };
|
||||
F4A9E9D5221C6DBA0031492C /* SPStorkTransitioningDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9CE221C6DBA0031492C /* SPStorkTransitioningDelegate.swift */; };
|
||||
F4A9E9D6221C6DBA0031492C /* SPStorkPresentingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9CF221C6DBA0031492C /* SPStorkPresentingAnimationController.swift */; };
|
||||
F4A9E9D7221C6DBA0031492C /* SPStorkPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9D0221C6DBA0031492C /* SPStorkPresentationController.swift */; };
|
||||
F4A9E9D8221C6DBA0031492C /* SPStorkController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9D1221C6DBA0031492C /* SPStorkController.swift */; };
|
||||
F4A9E9D9221C6DBA0031492C /* SPStorkIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9D2221C6DBA0031492C /* SPStorkIndicatorView.swift */; };
|
||||
F4A9E9DA221C6DBA0031492C /* SPStorkDismissingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A9E9D3221C6DBA0031492C /* SPStorkDismissingAnimationController.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
F40DB6FB222A9202004E1CCB /* SPStorkViewControllerExtenshion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkViewControllerExtenshion.swift; sourceTree = "<group>"; };
|
||||
F40DB6FC222A9202004E1CCB /* SPStorkTransitioningDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkTransitioningDelegate.swift; sourceTree = "<group>"; };
|
||||
F40DB6FD222A9202004E1CCB /* SPStorkPresentingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentingAnimationController.swift; sourceTree = "<group>"; };
|
||||
F40DB6FE222A9202004E1CCB /* SPStorkPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentationController.swift; sourceTree = "<group>"; };
|
||||
F40DB6FF222A9202004E1CCB /* SPStorkController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkController.swift; sourceTree = "<group>"; };
|
||||
F40DB700222A9202004E1CCB /* SPStorkIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkIndicatorView.swift; sourceTree = "<group>"; };
|
||||
F40DB701222A9202004E1CCB /* SPStorkDismissingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkDismissingAnimationController.swift; sourceTree = "<group>"; };
|
||||
F445CA8321AED92600184254 /* stork-controller.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "stork-controller.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F445CA8621AED92600184254 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
F445CA8821AED92600184254 /* Controller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Controller.swift; sourceTree = "<group>"; };
|
||||
@@ -267,13 +274,6 @@
|
||||
F4552721221C009D00F40446 /* SPShare.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPShare.swift; sourceTree = "<group>"; };
|
||||
F459D75A21C3AB9A00798524 /* ModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalViewController.swift; sourceTree = "<group>"; };
|
||||
F459D75C21C3ABBD00798524 /* ModalTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalTableViewController.swift; sourceTree = "<group>"; };
|
||||
F4A9E9CD221C6DBA0031492C /* SPStorkViewControllerExtenshion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkViewControllerExtenshion.swift; sourceTree = "<group>"; };
|
||||
F4A9E9CE221C6DBA0031492C /* SPStorkTransitioningDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkTransitioningDelegate.swift; sourceTree = "<group>"; };
|
||||
F4A9E9CF221C6DBA0031492C /* SPStorkPresentingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentingAnimationController.swift; sourceTree = "<group>"; };
|
||||
F4A9E9D0221C6DBA0031492C /* SPStorkPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentationController.swift; sourceTree = "<group>"; };
|
||||
F4A9E9D1221C6DBA0031492C /* SPStorkController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkController.swift; sourceTree = "<group>"; };
|
||||
F4A9E9D2221C6DBA0031492C /* SPStorkIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkIndicatorView.swift; sourceTree = "<group>"; };
|
||||
F4A9E9D3221C6DBA0031492C /* SPStorkDismissingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkDismissingAnimationController.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -287,6 +287,20 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
F40DB6FA222A9202004E1CCB /* SPStorkController */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F40DB6FB222A9202004E1CCB /* SPStorkViewControllerExtenshion.swift */,
|
||||
F40DB6FC222A9202004E1CCB /* SPStorkTransitioningDelegate.swift */,
|
||||
F40DB6FD222A9202004E1CCB /* SPStorkPresentingAnimationController.swift */,
|
||||
F40DB6FE222A9202004E1CCB /* SPStorkPresentationController.swift */,
|
||||
F40DB6FF222A9202004E1CCB /* SPStorkController.swift */,
|
||||
F40DB700222A9202004E1CCB /* SPStorkIndicatorView.swift */,
|
||||
F40DB701222A9202004E1CCB /* SPStorkDismissingAnimationController.swift */,
|
||||
);
|
||||
path = SPStorkController;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F445CA7A21AED92600184254 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -322,7 +336,7 @@
|
||||
F445CA9821AED98500184254 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F4A9E9CC221C6DBA0031492C /* SPStorkController */,
|
||||
F40DB6FA222A9202004E1CCB /* SPStorkController */,
|
||||
F4552681221C009D00F40446 /* SparrowKit */,
|
||||
);
|
||||
path = Frameworks;
|
||||
@@ -789,20 +803,6 @@
|
||||
path = Share;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F4A9E9CC221C6DBA0031492C /* SPStorkController */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F4A9E9CD221C6DBA0031492C /* SPStorkViewControllerExtenshion.swift */,
|
||||
F4A9E9CE221C6DBA0031492C /* SPStorkTransitioningDelegate.swift */,
|
||||
F4A9E9CF221C6DBA0031492C /* SPStorkPresentingAnimationController.swift */,
|
||||
F4A9E9D0221C6DBA0031492C /* SPStorkPresentationController.swift */,
|
||||
F4A9E9D1221C6DBA0031492C /* SPStorkController.swift */,
|
||||
F4A9E9D2221C6DBA0031492C /* SPStorkIndicatorView.swift */,
|
||||
F4A9E9D3221C6DBA0031492C /* SPStorkDismissingAnimationController.swift */,
|
||||
);
|
||||
path = SPStorkController;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -882,11 +882,11 @@
|
||||
F455277E221C009E00F40446 /* SPAppBadge.swift in Sources */,
|
||||
F4552756221C009E00F40446 /* SPGolubevIconView.swift in Sources */,
|
||||
F4552752221C009E00F40446 /* SPCenterLabelsView.swift in Sources */,
|
||||
F4A9E9D4221C6DBA0031492C /* SPStorkViewControllerExtenshion.swift in Sources */,
|
||||
F40DB702222A9202004E1CCB /* SPStorkViewControllerExtenshion.swift in Sources */,
|
||||
F4552776221C009E00F40446 /* SPUILabelExtenshion.swift in Sources */,
|
||||
F445CA8921AED92600184254 /* Controller.swift in Sources */,
|
||||
F4552775221C009E00F40446 /* SPCGRectExtension.swift in Sources */,
|
||||
F4A9E9D8221C6DBA0031492C /* SPStorkController.swift in Sources */,
|
||||
F40DB706222A9202004E1CCB /* SPStorkController.swift in Sources */,
|
||||
F4552779221C009E00F40446 /* SPUIImageViewExtenshion.swift in Sources */,
|
||||
F455278B221C009E00F40446 /* SPAnimationAlpha.swift in Sources */,
|
||||
F455273A221C009E00F40446 /* SPAppleMusicSectionButtonsView.swift in Sources */,
|
||||
@@ -900,9 +900,9 @@
|
||||
F455273F221C009E00F40446 /* SPButton.swift in Sources */,
|
||||
F4552759221C009E00F40446 /* SPTableController.swift in Sources */,
|
||||
F4552786221C009E00F40446 /* SPLayout.swift in Sources */,
|
||||
F4A9E9DA221C6DBA0031492C /* SPStorkDismissingAnimationController.swift in Sources */,
|
||||
F40DB708222A9202004E1CCB /* SPStorkDismissingAnimationController.swift in Sources */,
|
||||
F455279E221C009E00F40446 /* SPShare.swift in Sources */,
|
||||
F4A9E9D5221C6DBA0031492C /* SPStorkTransitioningDelegate.swift in Sources */,
|
||||
F40DB703222A9202004E1CCB /* SPStorkTransitioningDelegate.swift in Sources */,
|
||||
F4552774221C009E00F40446 /* SPUINavigationControllerExtenshion.swift in Sources */,
|
||||
F455275B221C009E00F40446 /* SPController.swift in Sources */,
|
||||
F455279A221C009E00F40446 /* SPGolubevGolubevIconPack.swift in Sources */,
|
||||
@@ -925,7 +925,7 @@
|
||||
F455276D221C009E00F40446 /* SPUIViewControllerExtenshion.swift in Sources */,
|
||||
F4552736221C009D00F40446 /* SPTableViewCell.swift in Sources */,
|
||||
F459D75D21C3ABBD00798524 /* ModalTableViewController.swift in Sources */,
|
||||
F4A9E9D7221C6DBA0031492C /* SPStorkPresentationController.swift in Sources */,
|
||||
F40DB705222A9202004E1CCB /* SPStorkPresentationController.swift in Sources */,
|
||||
F4552798221C009E00F40446 /* SPCodeSystemIconPack.swift in Sources */,
|
||||
F4552769221C009E00F40446 /* SPUITableView.swift in Sources */,
|
||||
F455277A221C009E00F40446 /* SPUIColorExtension.swift in Sources */,
|
||||
@@ -958,7 +958,7 @@
|
||||
F455274B221C009E00F40446 /* SPGradientView.swift in Sources */,
|
||||
F4552747221C009E00F40446 /* SPTextView.swift in Sources */,
|
||||
F455275C221C009E00F40446 /* SPCollectionViewCell.swift in Sources */,
|
||||
F4A9E9D6221C6DBA0031492C /* SPStorkPresentingAnimationController.swift in Sources */,
|
||||
F40DB704222A9202004E1CCB /* SPStorkPresentingAnimationController.swift in Sources */,
|
||||
F4552764221C009E00F40446 /* SPUIAlertControllerExtenshion.swift in Sources */,
|
||||
F4552787221C009E00F40446 /* SPShadow.swift in Sources */,
|
||||
F4552740221C009E00F40446 /* SPAppStoreActionButton.swift in Sources */,
|
||||
@@ -973,7 +973,7 @@
|
||||
F459D75B21C3AB9A00798524 /* ModalViewController.swift in Sources */,
|
||||
F4552771221C009E00F40446 /* SPUICollectionViewExtenshion.swift in Sources */,
|
||||
F455277D221C009E00F40446 /* SPApp.swift in Sources */,
|
||||
F4A9E9D9221C6DBA0031492C /* SPStorkIndicatorView.swift in Sources */,
|
||||
F40DB707222A9202004E1CCB /* SPStorkIndicatorView.swift in Sources */,
|
||||
F455274E221C009E00F40446 /* SPBlurView.swift in Sources */,
|
||||
F4552784221C009E00F40446 /* SPLocalNotification.swift in Sources */,
|
||||
F4552757221C009E00F40446 /* SPProposeController.swift in Sources */,
|
||||
|
||||
BIN
Binary file not shown.
@@ -28,26 +28,20 @@ public struct SPStorkController {
|
||||
if let presentationController = controller.presentationController as? SPStorkPresentationController {
|
||||
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
|
||||
if translation >= 0 {
|
||||
|
||||
if controller.isBeingPresented { return }
|
||||
|
||||
scrollView.subviews.forEach {
|
||||
$0.transform = CGAffineTransform(translationX: 0, y: -translation)
|
||||
}
|
||||
|
||||
presentationController.setIndicator(style: scrollView.isDragging ? .line : .arrow)
|
||||
|
||||
if translation >= presentationController.translateForDismiss * 0.65 {
|
||||
if !scrollView.isDragging {
|
||||
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
|
||||
if translation >= presentationController.translateForDismiss * 0.4 {
|
||||
if !scrollView.isTracking && !scrollView.isDragging {
|
||||
presentationController.presentedViewController.dismiss(animated: true, completion: nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if presentationController.pan?.state != UIGestureRecognizer.State.changed {
|
||||
presentationController.scrollViewDidScroll(translation)
|
||||
presentationController.scrollViewDidScroll(translation * 2)
|
||||
}
|
||||
|
||||
} else {
|
||||
presentationController.setIndicator(style: .arrow)
|
||||
presentationController.scrollViewDidScroll(0)
|
||||
@@ -56,6 +50,10 @@ public struct SPStorkController {
|
||||
}
|
||||
}
|
||||
|
||||
static var topScrollIndicatorInset: CGFloat {
|
||||
return 6
|
||||
}
|
||||
|
||||
static public func updatePresentingController(parent controller: UIViewController) {
|
||||
if let presentationController = controller.presentedViewController?.presentationController as? SPStorkPresentationController {
|
||||
presentationController.updatePresentingController()
|
||||
|
||||
+10
-11
@@ -28,7 +28,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
var showIndicator: Bool = true
|
||||
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
var customHeight: CGFloat? = nil
|
||||
var translateForDismiss: CGFloat = 240
|
||||
var translateForDismiss: CGFloat = 200
|
||||
|
||||
var transitioningDelegate: SPStorkTransitioningDelegate?
|
||||
|
||||
@@ -44,6 +44,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
private var snapshotViewTopConstraint: NSLayoutConstraint?
|
||||
private var snapshotViewWidthConstraint: NSLayoutConstraint?
|
||||
private var snapshotViewAspectRatioConstraint: NSLayoutConstraint?
|
||||
|
||||
private var workGester: Bool = false
|
||||
private var startDismissing: Bool = false
|
||||
|
||||
@@ -52,13 +53,8 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
return (statusBarHeight < 25) ? 30 : statusBarHeight
|
||||
}
|
||||
|
||||
private var alpha: CGFloat {
|
||||
return 0.51
|
||||
}
|
||||
|
||||
private var cornerRadius: CGFloat {
|
||||
return 10
|
||||
}
|
||||
private let alpha: CGFloat = 0.51
|
||||
var cornerRadius: CGFloat = 10
|
||||
|
||||
private var scaleForPresentingView: CGFloat {
|
||||
guard let containerView = containerView else { return 0 }
|
||||
@@ -348,9 +344,12 @@ extension SPStorkPresentationController {
|
||||
|
||||
self.presentedView?.transform = CGAffineTransform(translationX: 0, y: translationForModal)
|
||||
|
||||
let factor = 1 + (translationForModal / 6000)
|
||||
self.snapshotView?.transform = CGAffineTransform.init(scaleX: factor, y: factor)
|
||||
self.gradeView.alpha = self.alpha - ((factor - 1) * 15)
|
||||
let scaleFactor = 1 + (translationForModal / 5000)
|
||||
self.snapshotView?.transform = CGAffineTransform.init(scaleX: scaleFactor, y: scaleFactor)
|
||||
let gradeFactor = 1 + (translationForModal / 7000)
|
||||
self.gradeView.alpha = self.alpha - ((gradeFactor - 1) * 15)
|
||||
} else {
|
||||
self.presentedView?.transform = CGAffineTransform.identity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -28,7 +28,8 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
public var showIndicator: Bool = true
|
||||
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
public var customHeight: CGFloat? = nil
|
||||
public var translateForDismiss: CGFloat = 240
|
||||
public var translateForDismiss: CGFloat = 200
|
||||
public var cornerRadius: CGFloat = 10
|
||||
|
||||
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
|
||||
let controller = SPStorkPresentationController(presentedViewController: presented, presenting: presenting)
|
||||
@@ -38,6 +39,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
controller.indicatorColor = self.indicatorColor
|
||||
controller.customHeight = self.customHeight
|
||||
controller.translateForDismiss = self.translateForDismiss
|
||||
controller.cornerRadius = self.cornerRadius
|
||||
controller.transitioningDelegate = self
|
||||
return controller
|
||||
}
|
||||
|
||||
+2
-1
@@ -29,9 +29,10 @@ extension UIViewController {
|
||||
&& presentingViewController != nil
|
||||
}
|
||||
|
||||
public func presentAsStork(_ controller: UIViewController, height: CGFloat? = nil, complection: (() -> Void)? = nil) {
|
||||
public func presentAsStork(_ controller: UIViewController, height: CGFloat? = nil, showIndicator: Bool = false, complection: (() -> Void)? = nil) {
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
transitionDelegate.customHeight = height
|
||||
transitionDelegate.showIndicator = showIndicator
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
controller.modalPresentationCapturesStatusBarAppearance = true
|
||||
|
||||
@@ -120,6 +120,11 @@ transitionDelegate.showIndicator = true
|
||||
transitionDelegate.indicatorColor = UIColor.white
|
||||
```
|
||||
|
||||
- Parameter `cornerRadius` for customize corner radius of controller's view. Default is `10`:
|
||||
```swift
|
||||
transitionDelegate.cornerRadius = 10
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
|
||||
The project uses a snapshot of the screen in order to avoid compatibility and customization issues. Before controller presentation, a snapshot of the parent view is made, and size and position are changed for the snapshot. Sometimes you will need to update the screenshot of the parent view, for that use static func:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SPStorkController"
|
||||
s.version = "1.5"
|
||||
s.version = "1.5.2"
|
||||
s.summary = "Modal controller as mail or Apple music application"
|
||||
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
|
||||
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
|
||||
|
||||
@@ -28,26 +28,20 @@ public struct SPStorkController {
|
||||
if let presentationController = controller.presentationController as? SPStorkPresentationController {
|
||||
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
|
||||
if translation >= 0 {
|
||||
|
||||
if controller.isBeingPresented { return }
|
||||
|
||||
scrollView.subviews.forEach {
|
||||
$0.transform = CGAffineTransform(translationX: 0, y: -translation)
|
||||
}
|
||||
|
||||
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
|
||||
|
||||
if translation >= presentationController.translateForDismiss * 0.4 {
|
||||
if !scrollView.isTracking && !scrollView.isDragging {
|
||||
presentationController.presentedViewController.dismiss(animated: true, completion: nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if presentationController.pan?.state != UIGestureRecognizer.State.changed {
|
||||
presentationController.scrollViewDidScroll(translation * 2)
|
||||
}
|
||||
|
||||
} else {
|
||||
presentationController.setIndicator(style: .arrow)
|
||||
presentationController.scrollViewDidScroll(0)
|
||||
@@ -56,6 +50,10 @@ public struct SPStorkController {
|
||||
}
|
||||
}
|
||||
|
||||
static var topScrollIndicatorInset: CGFloat {
|
||||
return 6
|
||||
}
|
||||
|
||||
static public func updatePresentingController(parent controller: UIViewController) {
|
||||
if let presentationController = controller.presentedViewController?.presentationController as? SPStorkPresentationController {
|
||||
presentationController.updatePresentingController()
|
||||
|
||||
@@ -44,6 +44,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
private var snapshotViewTopConstraint: NSLayoutConstraint?
|
||||
private var snapshotViewWidthConstraint: NSLayoutConstraint?
|
||||
private var snapshotViewAspectRatioConstraint: NSLayoutConstraint?
|
||||
|
||||
private var workGester: Bool = false
|
||||
private var startDismissing: Bool = false
|
||||
|
||||
@@ -52,13 +53,8 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
return (statusBarHeight < 25) ? 30 : statusBarHeight
|
||||
}
|
||||
|
||||
private var alpha: CGFloat {
|
||||
return 0.51
|
||||
}
|
||||
|
||||
private var cornerRadius: CGFloat {
|
||||
return 10
|
||||
}
|
||||
private let alpha: CGFloat = 0.51
|
||||
var cornerRadius: CGFloat = 10
|
||||
|
||||
private var scaleForPresentingView: CGFloat {
|
||||
guard let containerView = containerView else { return 0 }
|
||||
@@ -352,6 +348,8 @@ extension SPStorkPresentationController {
|
||||
self.snapshotView?.transform = CGAffineTransform.init(scaleX: scaleFactor, y: scaleFactor)
|
||||
let gradeFactor = 1 + (translationForModal / 7000)
|
||||
self.gradeView.alpha = self.alpha - ((gradeFactor - 1) * 15)
|
||||
} else {
|
||||
self.presentedView?.transform = CGAffineTransform.identity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
public var customHeight: CGFloat? = nil
|
||||
public var translateForDismiss: CGFloat = 200
|
||||
public var cornerRadius: CGFloat = 10
|
||||
|
||||
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
|
||||
let controller = SPStorkPresentationController(presentedViewController: presented, presenting: presenting)
|
||||
@@ -38,6 +39,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
controller.indicatorColor = self.indicatorColor
|
||||
controller.customHeight = self.customHeight
|
||||
controller.translateForDismiss = self.translateForDismiss
|
||||
controller.cornerRadius = self.cornerRadius
|
||||
controller.transitioningDelegate = self
|
||||
return controller
|
||||
}
|
||||
|
||||
@@ -29,9 +29,10 @@ extension UIViewController {
|
||||
&& presentingViewController != nil
|
||||
}
|
||||
|
||||
public func presentAsStork(_ controller: UIViewController, height: CGFloat? = nil, complection: (() -> Void)? = nil) {
|
||||
public func presentAsStork(_ controller: UIViewController, height: CGFloat? = nil, showIndicator: Bool = false, complection: (() -> Void)? = nil) {
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
transitionDelegate.customHeight = height
|
||||
transitionDelegate.showIndicator = showIndicator
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
controller.modalPresentationCapturesStatusBarAppearance = true
|
||||
|
||||
Reference in New Issue
Block a user