Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5371ca20c | |||
| fdbc1e3527 | |||
| 306547671c | |||
| 1fede9eb64 | |||
| 3ef2ff81bc | |||
| 83330bb509 | |||
| c4da6ff27e | |||
| 686bbd749b | |||
| 7b151fd268 | |||
| 7bdf702703 | |||
| 0d1381d941 |
@@ -7,17 +7,17 @@
|
||||
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 */; };
|
||||
F445CA9121AED92700184254 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F445CA8F21AED92700184254 /* LaunchScreen.storyboard */; };
|
||||
F4552722221C009D00F40446 /* SPStorkViewControllerExtenshion.swift in Sources */ = {isa = PBXBuildFile; fileRef = F455267A221C009D00F40446 /* SPStorkViewControllerExtenshion.swift */; };
|
||||
F4552723221C009D00F40446 /* SPStorkTransitioningDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F455267B221C009D00F40446 /* SPStorkTransitioningDelegate.swift */; };
|
||||
F4552724221C009D00F40446 /* SPStorkPresentingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F455267C221C009D00F40446 /* SPStorkPresentingAnimationController.swift */; };
|
||||
F4552725221C009D00F40446 /* SPStorkPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F455267D221C009D00F40446 /* SPStorkPresentationController.swift */; };
|
||||
F4552726221C009D00F40446 /* SPStorkController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F455267E221C009D00F40446 /* SPStorkController.swift */; };
|
||||
F4552727221C009D00F40446 /* SPStorkIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F455267F221C009D00F40446 /* SPStorkIndicatorView.swift */; };
|
||||
F4552728221C009D00F40446 /* SPStorkDismissingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4552680221C009D00F40446 /* SPStorkDismissingAnimationController.swift */; };
|
||||
F4552729221C009D00F40446 /* SPVibration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4552683221C009D00F40446 /* SPVibration.swift */; };
|
||||
F455272A221C009D00F40446 /* SPPromoTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4552687221C009D00F40446 /* SPPromoTableViewCell.swift */; };
|
||||
F455272B221C009D00F40446 /* SPFormButtonTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4552689221C009D00F40446 /* SPFormButtonTableViewCell.swift */; };
|
||||
@@ -141,19 +141,19 @@
|
||||
/* 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>"; };
|
||||
F445CA8D21AED92700184254 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
F445CA9021AED92700184254 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
F445CA9221AED92700184254 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
F455267A221C009D00F40446 /* SPStorkViewControllerExtenshion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkViewControllerExtenshion.swift; sourceTree = "<group>"; };
|
||||
F455267B221C009D00F40446 /* SPStorkTransitioningDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkTransitioningDelegate.swift; sourceTree = "<group>"; };
|
||||
F455267C221C009D00F40446 /* SPStorkPresentingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentingAnimationController.swift; sourceTree = "<group>"; };
|
||||
F455267D221C009D00F40446 /* SPStorkPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentationController.swift; sourceTree = "<group>"; };
|
||||
F455267E221C009D00F40446 /* SPStorkController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkController.swift; sourceTree = "<group>"; };
|
||||
F455267F221C009D00F40446 /* SPStorkIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkIndicatorView.swift; sourceTree = "<group>"; };
|
||||
F4552680221C009D00F40446 /* SPStorkDismissingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkDismissingAnimationController.swift; sourceTree = "<group>"; };
|
||||
F4552683221C009D00F40446 /* SPVibration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPVibration.swift; sourceTree = "<group>"; };
|
||||
F4552687221C009D00F40446 /* SPPromoTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPPromoTableViewCell.swift; sourceTree = "<group>"; };
|
||||
F4552689221C009D00F40446 /* SPFormButtonTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPFormButtonTableViewCell.swift; sourceTree = "<group>"; };
|
||||
@@ -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,26 +336,12 @@
|
||||
F445CA9821AED98500184254 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F40DB6FA222A9202004E1CCB /* SPStorkController */,
|
||||
F4552681221C009D00F40446 /* SparrowKit */,
|
||||
F4552679221C009D00F40446 /* SPStorkController */,
|
||||
);
|
||||
path = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F4552679221C009D00F40446 /* SPStorkController */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F455267A221C009D00F40446 /* SPStorkViewControllerExtenshion.swift */,
|
||||
F455267B221C009D00F40446 /* SPStorkTransitioningDelegate.swift */,
|
||||
F455267C221C009D00F40446 /* SPStorkPresentingAnimationController.swift */,
|
||||
F455267D221C009D00F40446 /* SPStorkPresentationController.swift */,
|
||||
F455267E221C009D00F40446 /* SPStorkController.swift */,
|
||||
F455267F221C009D00F40446 /* SPStorkIndicatorView.swift */,
|
||||
F4552680221C009D00F40446 /* SPStorkDismissingAnimationController.swift */,
|
||||
);
|
||||
path = SPStorkController;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F4552681221C009D00F40446 /* SparrowKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -875,7 +875,6 @@
|
||||
files = (
|
||||
F455276B221C009E00F40446 /* SPArrayExtension.swift in Sources */,
|
||||
F455276F221C009E00F40446 /* SPStrideableExtension.swift in Sources */,
|
||||
F4552726221C009D00F40446 /* SPStorkController.swift in Sources */,
|
||||
F4552729221C009D00F40446 /* SPVibration.swift in Sources */,
|
||||
F4552760221C009E00F40446 /* SPCollectionView.swift in Sources */,
|
||||
F4552744221C009E00F40446 /* SPFakeBarView.swift in Sources */,
|
||||
@@ -883,9 +882,11 @@
|
||||
F455277E221C009E00F40446 /* SPAppBadge.swift in Sources */,
|
||||
F4552756221C009E00F40446 /* SPGolubevIconView.swift in Sources */,
|
||||
F4552752221C009E00F40446 /* SPCenterLabelsView.swift in Sources */,
|
||||
F40DB702222A9202004E1CCB /* SPStorkViewControllerExtenshion.swift in Sources */,
|
||||
F4552776221C009E00F40446 /* SPUILabelExtenshion.swift in Sources */,
|
||||
F445CA8921AED92600184254 /* Controller.swift in Sources */,
|
||||
F4552775221C009E00F40446 /* SPCGRectExtension.swift in Sources */,
|
||||
F40DB706222A9202004E1CCB /* SPStorkController.swift in Sources */,
|
||||
F4552779221C009E00F40446 /* SPUIImageViewExtenshion.swift in Sources */,
|
||||
F455278B221C009E00F40446 /* SPAnimationAlpha.swift in Sources */,
|
||||
F455273A221C009E00F40446 /* SPAppleMusicSectionButtonsView.swift in Sources */,
|
||||
@@ -899,7 +900,9 @@
|
||||
F455273F221C009E00F40446 /* SPButton.swift in Sources */,
|
||||
F4552759221C009E00F40446 /* SPTableController.swift in Sources */,
|
||||
F4552786221C009E00F40446 /* SPLayout.swift in Sources */,
|
||||
F40DB708222A9202004E1CCB /* SPStorkDismissingAnimationController.swift in Sources */,
|
||||
F455279E221C009E00F40446 /* SPShare.swift in Sources */,
|
||||
F40DB703222A9202004E1CCB /* SPStorkTransitioningDelegate.swift in Sources */,
|
||||
F4552774221C009E00F40446 /* SPUINavigationControllerExtenshion.swift in Sources */,
|
||||
F455275B221C009E00F40446 /* SPController.swift in Sources */,
|
||||
F455279A221C009E00F40446 /* SPGolubevGolubevIconPack.swift in Sources */,
|
||||
@@ -911,7 +914,6 @@
|
||||
F4552749221C009E00F40446 /* SPDownloadingUIImageView.swift in Sources */,
|
||||
F4552751221C009E00F40446 /* SPLabel.swift in Sources */,
|
||||
F455276A221C009E00F40446 /* SPUIViewExtenshion.swift in Sources */,
|
||||
F4552723221C009D00F40446 /* SPStorkTransitioningDelegate.swift in Sources */,
|
||||
F4552794221C009E00F40446 /* SPAudio.swift in Sources */,
|
||||
F455279C221C009E00F40446 /* SPRandom.swift in Sources */,
|
||||
F4552778221C009E00F40446 /* SPCGSizeExtenshion.swift in Sources */,
|
||||
@@ -923,6 +925,7 @@
|
||||
F455276D221C009E00F40446 /* SPUIViewControllerExtenshion.swift in Sources */,
|
||||
F4552736221C009D00F40446 /* SPTableViewCell.swift in Sources */,
|
||||
F459D75D21C3ABBD00798524 /* ModalTableViewController.swift in Sources */,
|
||||
F40DB705222A9202004E1CCB /* SPStorkPresentationController.swift in Sources */,
|
||||
F4552798221C009E00F40446 /* SPCodeSystemIconPack.swift in Sources */,
|
||||
F4552769221C009E00F40446 /* SPUITableView.swift in Sources */,
|
||||
F455277A221C009E00F40446 /* SPUIColorExtension.swift in Sources */,
|
||||
@@ -935,7 +938,6 @@
|
||||
F455274C221C009E00F40446 /* SPSeparatorView.swift in Sources */,
|
||||
F455273C221C009E00F40446 /* SPSystemIconButton.swift in Sources */,
|
||||
F4552761221C009E00F40446 /* SPPageCollectionView.swift in Sources */,
|
||||
F4552728221C009D00F40446 /* SPStorkDismissingAnimationController.swift in Sources */,
|
||||
F4552767221C009E00F40446 /* SPUIFontExtenshion.swift in Sources */,
|
||||
F4552766221C009E00F40446 /* SPUITextFieldExtenshion.swift in Sources */,
|
||||
F4552772221C009E00F40446 /* SPTextFieldExtenshion.swift in Sources */,
|
||||
@@ -945,7 +947,6 @@
|
||||
F455272C221C009D00F40446 /* SPFormMailTableViewCell.swift in Sources */,
|
||||
F4552773221C009E00F40446 /* SPUITabBarControllerExtenshion.swift in Sources */,
|
||||
F4552737221C009E00F40446 /* SPTableView.swift in Sources */,
|
||||
F4552724221C009D00F40446 /* SPStorkPresentingAnimationController.swift in Sources */,
|
||||
F455278D221C009E00F40446 /* SPDownloader.swift in Sources */,
|
||||
F4552777221C009E00F40446 /* SPDateExtenshion.swift in Sources */,
|
||||
F4552782221C009E00F40446 /* SPLocalAuthentication.swift in Sources */,
|
||||
@@ -954,17 +955,16 @@
|
||||
F455275A221C009E00F40446 /* SPStatusBarManagerController.swift in Sources */,
|
||||
F4552792221C009E00F40446 /* SPInstagram.swift in Sources */,
|
||||
F455278F221C009E00F40446 /* SPTwitter.swift in Sources */,
|
||||
F4552725221C009D00F40446 /* SPStorkPresentationController.swift in Sources */,
|
||||
F455274B221C009E00F40446 /* SPGradientView.swift in Sources */,
|
||||
F4552747221C009E00F40446 /* SPTextView.swift in Sources */,
|
||||
F455275C221C009E00F40446 /* SPCollectionViewCell.swift in Sources */,
|
||||
F40DB704222A9202004E1CCB /* SPStorkPresentingAnimationController.swift in Sources */,
|
||||
F4552764221C009E00F40446 /* SPUIAlertControllerExtenshion.swift in Sources */,
|
||||
F4552787221C009E00F40446 /* SPShadow.swift in Sources */,
|
||||
F4552740221C009E00F40446 /* SPAppStoreActionButton.swift in Sources */,
|
||||
F455275E221C009E00F40446 /* SPCollectionViewLayout.swift in Sources */,
|
||||
F4552780221C009E00F40446 /* SPNativeColors.swift in Sources */,
|
||||
F455272E221C009D00F40446 /* SPFormTextFiledTableViewCell.swift in Sources */,
|
||||
F4552722221C009D00F40446 /* SPStorkViewControllerExtenshion.swift in Sources */,
|
||||
F445CA8721AED92600184254 /* AppDelegate.swift in Sources */,
|
||||
F4552738221C009E00F40446 /* SPPlayCircleButton.swift in Sources */,
|
||||
F4552754221C009E00F40446 /* SPSocialIconView.swift in Sources */,
|
||||
@@ -973,6 +973,7 @@
|
||||
F459D75B21C3AB9A00798524 /* ModalViewController.swift in Sources */,
|
||||
F4552771221C009E00F40446 /* SPUICollectionViewExtenshion.swift in Sources */,
|
||||
F455277D221C009E00F40446 /* SPApp.swift in Sources */,
|
||||
F40DB707222A9202004E1CCB /* SPStorkIndicatorView.swift in Sources */,
|
||||
F455274E221C009E00F40446 /* SPBlurView.swift in Sources */,
|
||||
F4552784221C009E00F40446 /* SPLocalNotification.swift in Sources */,
|
||||
F4552757221C009E00F40446 /* SPProposeController.swift in Sources */,
|
||||
@@ -981,7 +982,6 @@
|
||||
F4552734221C009D00F40446 /* SPProposeTableViewCell.swift in Sources */,
|
||||
F4552793221C009E00F40446 /* SPWhatsApp.swift in Sources */,
|
||||
F4552788221C009E00F40446 /* SPShadowDeep.swift in Sources */,
|
||||
F4552727221C009D00F40446 /* SPStorkIndicatorView.swift in Sources */,
|
||||
F4552763221C009E00F40446 /* SPLocale.swift in Sources */,
|
||||
F4552789221C009E00F40446 /* SPAnimationUpward.swift in Sources */,
|
||||
F4552795221C009E00F40446 /* SPAudioPlayer.swift in Sources */,
|
||||
|
||||
BIN
Binary file not shown.
Regular → Executable
+15
-7
@@ -25,27 +25,35 @@ public struct SPStorkController {
|
||||
|
||||
static public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if let controller = self.controller(for: scrollView) {
|
||||
if let presentationController = controller.presentationController as? SPStorkPresentationController,
|
||||
presentationController.swipeToDismissEnabled {
|
||||
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)
|
||||
}
|
||||
|
||||
if let pan = presentationController.pan,
|
||||
pan.state == .possible, pan.translation(in: controller.view).y <= 0 {
|
||||
presentationController.scrollViewDidScroll(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static var topScrollIndicatorInset: CGFloat {
|
||||
return 6
|
||||
}
|
||||
|
||||
static public func updatePresentingController(parent controller: UIViewController) {
|
||||
if let presentationController = controller.presentedViewController?.presentationController as? SPStorkPresentationController {
|
||||
presentationController.updatePresentingController()
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
+15
-19
@@ -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 }
|
||||
@@ -294,7 +290,7 @@ extension SPStorkPresentationController {
|
||||
self.workGester = false
|
||||
let translation = gestureRecognizer.translation(in: presentedView).y
|
||||
if translation >= self.translateForDismiss {
|
||||
presentedViewController.dismiss(animated: true, completion: nil)
|
||||
self.presentedViewController.dismiss(animated: true, completion: nil)
|
||||
} else {
|
||||
self.indicatorView.style = .arrow
|
||||
UIView.animate(
|
||||
@@ -325,6 +321,10 @@ extension SPStorkPresentationController {
|
||||
self.updateSnapshot()
|
||||
}
|
||||
|
||||
func setIndicator(style: SPStorkIndicatorView.Style) {
|
||||
self.indicatorView.style = style
|
||||
}
|
||||
|
||||
private func updatePresentedViewForTranslation(inVerticalDirection translation: CGFloat) {
|
||||
if self.startDismissing { return }
|
||||
|
||||
@@ -344,22 +344,18 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SPStorkPresentationController {
|
||||
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if swipeToDismissEnabled, let scrollView = otherGestureRecognizer.view as? UIScrollView{
|
||||
return scrollView.contentOffset.y <= 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override func containerViewWillLayoutSubviews() {
|
||||
super.containerViewWillLayoutSubviews()
|
||||
guard let containerView = containerView else { return }
|
||||
|
||||
Regular → Executable
Regular → Executable
+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
|
||||
}
|
||||
|
||||
Regular → Executable
+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
|
||||
|
||||
@@ -6,7 +6,7 @@ Preview GIF is loading `3mb`. Please, wait.
|
||||
|
||||
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Preview.gif" width="500">
|
||||
|
||||
You can download example [from AppStore](https://itunes.apple.com/app/id1446635818). Also in the app you can donate me a cup of coffee. If you want to buy source code of the app shown on the GIF above, please go to [xcode-shop.com](https://xcode-shop.com). Price: $200.
|
||||
You can download example [from AppStore](https://itunes.apple.com/app/id1446635818) or see [video preview](https://xcode-shop.com/assets/preview/debts.mov). If you want to buy source code of the full app (plus app for Apple Watch), please go to [xcode-shop.com](https://xcode-shop.com). Price: $200 only GitHub users!
|
||||
|
||||
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Shop.svg"/>
|
||||
|
||||
@@ -120,6 +120,16 @@ transitionDelegate.showIndicator = true
|
||||
transitionDelegate.indicatorColor = UIColor.white
|
||||
```
|
||||
|
||||
- Parameter `hideIndicatorWhenScroll` shows or hides indicator when scrolling. Default is `false`:
|
||||
```swift
|
||||
transitionDelegate.hideIndicatorWhenScroll = true
|
||||
```
|
||||
|
||||
- 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:
|
||||
@@ -135,6 +145,7 @@ You may want to add a navigation bar to your modal controller. Since it became i
|
||||
|
||||
```swift
|
||||
import UIKit
|
||||
import SPFakeBar
|
||||
|
||||
class ModalController: UIViewController {
|
||||
|
||||
@@ -158,15 +169,15 @@ You only need to add a navigation bar to the main view, it will automatically la
|
||||
|
||||
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Navigation%20Bar.jpg"/>
|
||||
|
||||
To use `SPFakeBarView` you need to install [SparrowKit](https://github.com/IvanVorobei/SparrowKit) pod:
|
||||
To use `SPFakeBarView` you need to install [SPFakeBar](https://github.com/IvanVorobei/SPFakeBar) pod:
|
||||
|
||||
```ruby
|
||||
pod 'SparrowKit'
|
||||
pod 'SPFakeBar'
|
||||
```
|
||||
|
||||
### Working with UIScrollView
|
||||
|
||||
If you use `UIScrollView` (or UITableView & UICollectionView) on your controller, I recommend making it more interactive. When scrolling reaches the top position, the controller will interactively drag down, simulating a closing animation. To do this, set the delegate and in the function `scrollViewDidScroll` call:
|
||||
If you use `UIScrollView` (or UITableView & UICollectionView) on your controller, I recommend making it more interactive. When scrolling reaches the top position, the controller will interactively drag down, simulating a closing animation. Also available close controller by drag down on `UIScrollView`. To do this, set the delegate and in the function `scrollViewDidScroll` call:
|
||||
|
||||
```swift
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
@@ -206,13 +217,6 @@ Project [SPPermission](https://github.com/IvanVorobei/SPPermission) for managing
|
||||
|
||||
<img src="https://github.com/IvanVorobei/SPPermission/blob/master/Resources/Preview.gif" width="500">
|
||||
|
||||
### SparrowKit
|
||||
`SPStorkController` was formerly a part of [SparrowKit](https://github.com/IvanVorobei/SparrowKit) library. In the library you can find many useful extensions & classes. To install via CocoaPods use:
|
||||
|
||||
```ruby
|
||||
pod 'SparrowKit'
|
||||
```
|
||||
|
||||
## License
|
||||
`SPStorkController` is released under the MIT license. Check `LICENSE.md` for details.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SPStorkController"
|
||||
s.version = "1.4.7"
|
||||
s.version = "1.5.5"
|
||||
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 }
|
||||
|
||||
Regular → Executable
+21
-7
@@ -25,27 +25,41 @@ public struct SPStorkController {
|
||||
|
||||
static public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if let controller = self.controller(for: scrollView) {
|
||||
if let presentationController = controller.presentationController as? SPStorkPresentationController,
|
||||
presentationController.swipeToDismissEnabled {
|
||||
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)
|
||||
}
|
||||
|
||||
if let pan = presentationController.pan,
|
||||
pan.state == .possible, pan.translation(in: controller.view).y <= 0 {
|
||||
presentationController.scrollViewDidScroll(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)
|
||||
}
|
||||
|
||||
if translation < -15 {
|
||||
presentationController.setIndicator(visible: false)
|
||||
} else {
|
||||
presentationController.setIndicator(visible: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static var topScrollIndicatorInset: CGFloat {
|
||||
return 6
|
||||
}
|
||||
|
||||
static public func updatePresentingController(parent controller: UIViewController) {
|
||||
if let presentationController = controller.presentedViewController?.presentationController as? SPStorkPresentationController {
|
||||
presentationController.updatePresentingController()
|
||||
|
||||
Regular → Executable
+3
-1
@@ -29,8 +29,10 @@ final class SPStorkDismissingAnimationController: NSObject, UIViewControllerAnim
|
||||
return
|
||||
}
|
||||
|
||||
let finalFrameForPresentedView = transitionContext.finalFrame(for: presentedViewController)
|
||||
|
||||
let containerView = transitionContext.containerView
|
||||
let offscreenFrame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
let offscreenFrame = CGRect(x: 0, y: containerView.bounds.height, width: finalFrameForPresentedView.width, height: finalFrameForPresentedView.height)
|
||||
|
||||
UIView.animate(
|
||||
withDuration: transitionDuration(using: transitionContext),
|
||||
|
||||
Regular → Executable
Regular → Executable
+36
-21
@@ -27,8 +27,9 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
var tapAroundToDismissEnabled: Bool = true
|
||||
var showIndicator: Bool = true
|
||||
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
var hideIndicatorWhenScroll: Bool = false
|
||||
var customHeight: CGFloat? = nil
|
||||
var translateForDismiss: CGFloat = 240
|
||||
var translateForDismiss: CGFloat = 200
|
||||
|
||||
var transitioningDelegate: SPStorkTransitioningDelegate?
|
||||
|
||||
@@ -44,6 +45,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 +54,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 }
|
||||
@@ -68,14 +65,20 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
|
||||
override var frameOfPresentedViewInContainerView: CGRect {
|
||||
guard let containerView = containerView else { return .zero }
|
||||
|
||||
var customHeight = self.customHeight ?? containerView.bounds.height
|
||||
if customHeight > containerView.bounds.height {
|
||||
customHeight = containerView.bounds.height
|
||||
print("SPStorkController - Custom height change to default value. Your height more maximum value")
|
||||
}
|
||||
let additionTranslate = containerView.bounds.height - customHeight
|
||||
let yOffset: CGFloat = self.topSpace + 13 + additionTranslate
|
||||
let yOffset: CGFloat = {
|
||||
if customHeight < containerView.bounds.height {
|
||||
return additionTranslate
|
||||
} else {
|
||||
return self.topSpace + 13 + additionTranslate
|
||||
}
|
||||
}()
|
||||
|
||||
return CGRect(x: 0, y: yOffset, width: containerView.bounds.width, height: containerView.bounds.height - yOffset)
|
||||
}
|
||||
|
||||
@@ -262,6 +265,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
self.backgroundView.removeFromSuperview()
|
||||
self.snapshotView?.removeFromSuperview()
|
||||
self.snapshotViewContainer.removeFromSuperview()
|
||||
self.indicatorView.removeFromSuperview()
|
||||
|
||||
let offscreenFrame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
presentedViewController.view.frame = offscreenFrame
|
||||
@@ -294,7 +298,7 @@ extension SPStorkPresentationController {
|
||||
self.workGester = false
|
||||
let translation = gestureRecognizer.translation(in: presentedView).y
|
||||
if translation >= self.translateForDismiss {
|
||||
presentedViewController.dismiss(animated: true, completion: nil)
|
||||
self.presentedViewController.dismiss(animated: true, completion: nil)
|
||||
} else {
|
||||
self.indicatorView.style = .arrow
|
||||
UIView.animate(
|
||||
@@ -325,6 +329,21 @@ extension SPStorkPresentationController {
|
||||
self.updateSnapshot()
|
||||
}
|
||||
|
||||
func setIndicator(style: SPStorkIndicatorView.Style) {
|
||||
self.indicatorView.style = style
|
||||
}
|
||||
|
||||
func setIndicator(visible: Bool) {
|
||||
guard self.hideIndicatorWhenScroll else { return }
|
||||
let newAlpha: CGFloat = visible ? 1 : 0
|
||||
if self.indicatorView.alpha == newAlpha {
|
||||
return
|
||||
}
|
||||
UIView.animate(withDuration: 0.15, animations: {
|
||||
self.indicatorView.alpha = newAlpha
|
||||
})
|
||||
}
|
||||
|
||||
private func updatePresentedViewForTranslation(inVerticalDirection translation: CGFloat) {
|
||||
if self.startDismissing { return }
|
||||
|
||||
@@ -344,22 +363,18 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SPStorkPresentationController {
|
||||
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
if swipeToDismissEnabled, let scrollView = otherGestureRecognizer.view as? UIScrollView{
|
||||
return scrollView.contentOffset.y <= 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override func containerViewWillLayoutSubviews() {
|
||||
super.containerViewWillLayoutSubviews()
|
||||
guard let containerView = containerView else { return }
|
||||
|
||||
Regular → Executable
Regular → Executable
+5
-1
@@ -27,8 +27,10 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
public var tapAroundToDismissEnabled: Bool = true
|
||||
public var showIndicator: Bool = true
|
||||
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
public var hideIndicatorWhenScroll: Bool = false
|
||||
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)
|
||||
@@ -36,8 +38,10 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
controller.tapAroundToDismissEnabled = self.tapAroundToDismissEnabled
|
||||
controller.showIndicator = self.showIndicator
|
||||
controller.indicatorColor = self.indicatorColor
|
||||
controller.hideIndicatorWhenScroll = self.hideIndicatorWhenScroll
|
||||
controller.customHeight = self.customHeight
|
||||
controller.translateForDismiss = self.translateForDismiss
|
||||
controller.cornerRadius = self.cornerRadius
|
||||
controller.transitioningDelegate = self
|
||||
return controller
|
||||
}
|
||||
|
||||
Regular → Executable
+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
|
||||
|
||||
Reference in New Issue
Block a user