From 9aaf16e6926899c779c2528374b774c3b71648af Mon Sep 17 00:00:00 2001 From: AHMET KAZIM GUNAY Date: Tue, 11 Jul 2017 20:03:26 +0300 Subject: [PATCH] deleted unneccessary files --- AKGPushAnimator.xcodeproj/project.pbxproj | 38 ++-- .../AKGInteractionAnimator.swift | 60 ------ .../AKGPushAnimator/AKGPushAnimator.swift | 172 ------------------ .../AKGPushAnimatorConstants.swift | 28 --- .../AKGPushAnimator.xcodeproj/project.pbxproj | 30 +-- .../AKGInteractionAnimator.swift | 60 ------ .../AKGPushAnimator/AKGPushAnimator.swift | 172 ------------------ .../AKGPushAnimatorConstants.swift | 28 --- 8 files changed, 30 insertions(+), 558 deletions(-) delete mode 100644 AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift delete mode 100644 AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift delete mode 100644 AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift delete mode 100644 Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift delete mode 100644 Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift delete mode 100644 Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift diff --git a/AKGPushAnimator.xcodeproj/project.pbxproj b/AKGPushAnimator.xcodeproj/project.pbxproj index 673a98b..162e73d 100644 --- a/AKGPushAnimator.xcodeproj/project.pbxproj +++ b/AKGPushAnimator.xcodeproj/project.pbxproj @@ -19,12 +19,9 @@ C31058731EBF3C4800C18F16 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058701EBF3C4800C18F16 /* BaseViewController.swift */; }; C31058741EBF3C4800C18F16 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058711EBF3C4800C18F16 /* FirstViewController.swift */; }; C31058751EBF3C4800C18F16 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058721EBF3C4800C18F16 /* SecondViewController.swift */; }; - C310587A1EBF3C5100C18F16 /* AKGInteractionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */; }; - C310587B1EBF3C5100C18F16 /* AKGPushAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */; }; - C310587C1EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */; }; - C310587D1EBF3D3B00C18F16 /* AKGInteractionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */; }; - C310587E1EBF3D3B00C18F16 /* AKGPushAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */; }; - C310587F1EBF3D3B00C18F16 /* AKGPushAnimatorConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */; }; + C3634D441F153BDC00DDF5B0 /* AKGInteractionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3634D411F153BDC00DDF5B0 /* AKGInteractionAnimator.swift */; }; + C3634D451F153BDC00DDF5B0 /* AKGPushAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3634D421F153BDC00DDF5B0 /* AKGPushAnimator.swift */; }; + C3634D461F153BDC00DDF5B0 /* AKGPushAnimatorConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3634D431F153BDC00DDF5B0 /* AKGPushAnimatorConstants.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -84,9 +81,9 @@ C31058701EBF3C4800C18F16 /* BaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = ""; }; C31058711EBF3C4800C18F16 /* FirstViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = ""; }; C31058721EBF3C4800C18F16 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; - C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AKGInteractionAnimator.swift; sourceTree = ""; }; - C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AKGPushAnimator.swift; sourceTree = ""; }; - C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AKGPushAnimatorConstants.swift; sourceTree = ""; }; + C3634D411F153BDC00DDF5B0 /* AKGInteractionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AKGInteractionAnimator.swift; path = Source/AKGInteractionAnimator.swift; sourceTree = SOURCE_ROOT; }; + C3634D421F153BDC00DDF5B0 /* AKGPushAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AKGPushAnimator.swift; path = Source/AKGPushAnimator.swift; sourceTree = SOURCE_ROOT; }; + C3634D431F153BDC00DDF5B0 /* AKGPushAnimatorConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AKGPushAnimatorConstants.swift; path = Source/AKGPushAnimatorConstants.swift; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -147,7 +144,7 @@ C310582F1EBF3B3400C18F16 /* AKGPushAnimator */ = { isa = PBXGroup; children = ( - C31058761EBF3C5100C18F16 /* AKGPushAnimator */, + C3634D401F153B7300DDF5B0 /* Source */, C31058701EBF3C4800C18F16 /* BaseViewController.swift */, C31058711EBF3C4800C18F16 /* FirstViewController.swift */, C31058721EBF3C4800C18F16 /* SecondViewController.swift */, @@ -187,14 +184,14 @@ path = AKGPushAnimatorKit; sourceTree = ""; }; - C31058761EBF3C5100C18F16 /* AKGPushAnimator */ = { + C3634D401F153B7300DDF5B0 /* Source */ = { isa = PBXGroup; children = ( - C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */, - C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */, - C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */, + C3634D411F153BDC00DDF5B0 /* AKGInteractionAnimator.swift */, + C3634D421F153BDC00DDF5B0 /* AKGPushAnimator.swift */, + C3634D431F153BDC00DDF5B0 /* AKGPushAnimatorConstants.swift */, ); - path = AKGPushAnimator; + name = Source; sourceTree = ""; }; /* End PBXGroup section */ @@ -378,13 +375,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C310587B1EBF3C5100C18F16 /* AKGPushAnimator.swift in Sources */, - C310587A1EBF3C5100C18F16 /* AKGInteractionAnimator.swift in Sources */, C31058311EBF3B3400C18F16 /* AppDelegate.swift in Sources */, - C310587C1EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift in Sources */, C31058731EBF3C4800C18F16 /* BaseViewController.swift in Sources */, C31058751EBF3C4800C18F16 /* SecondViewController.swift in Sources */, C31058741EBF3C4800C18F16 /* FirstViewController.swift in Sources */, + C3634D461F153BDC00DDF5B0 /* AKGPushAnimatorConstants.swift in Sources */, + C3634D451F153BDC00DDF5B0 /* AKGPushAnimator.swift in Sources */, + C3634D441F153BDC00DDF5B0 /* AKGInteractionAnimator.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -408,9 +405,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C310587D1EBF3D3B00C18F16 /* AKGInteractionAnimator.swift in Sources */, - C310587E1EBF3D3B00C18F16 /* AKGPushAnimator.swift in Sources */, - C310587F1EBF3D3B00C18F16 /* AKGPushAnimatorConstants.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -550,7 +544,6 @@ C31058561EBF3B3400C18F16 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = KUKEJWK3NR; INFOPLIST_FILE = AKGPushAnimator/Info.plist; @@ -564,7 +557,6 @@ C31058571EBF3B3400C18F16 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = KUKEJWK3NR; INFOPLIST_FILE = AKGPushAnimator/Info.plist; diff --git a/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift b/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift deleted file mode 100644 index 7341e10..0000000 --- a/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// AKGInteractionAnimator.swift -// AKGPushAnimatorDemo -// -// Created by AHMET KAZIM GUNAY on 30/04/2017. -// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved. -// - -import UIKit - -public class AKGInteractionAnimator: UIPercentDrivenInteractiveTransition { - - var navigationController: UINavigationController! - var shouldCompleteTransition = false - public var transitionInProgress = false - - public func attachToViewController(_ viewController: UIViewController) { - navigationController = viewController.navigationController - addGestureRecognizer(viewController.view) - } - - fileprivate func addGestureRecognizer(_ view: UIView) { - let panGesture = UIPanGestureRecognizer(target: self, action: #selector(AKGInteractionAnimator.handlePanGesture(_:))) - panGesture.delegate = self - view.addGestureRecognizer(panGesture) - } - - func handlePanGesture(_ gestureRecognizer: UIPanGestureRecognizer) { - let viewTranslation = gestureRecognizer.translation(in: gestureRecognizer.view?.superview) - let velocity : CGPoint = gestureRecognizer.velocity(in: gestureRecognizer.view) - - switch gestureRecognizer.state { - case .began: - transitionInProgress = true - navigationController.popViewController(animated: true) - case .changed: - var const = CGFloat(viewTranslation.x / UIScreen.main.bounds.width * 1.0) - const = min(1.0, max(0.0, const)) - shouldCompleteTransition = const > 0.5 || velocity.x > UIScreen.main.bounds.width - update(const) - case .cancelled, .ended: - transitionInProgress = false - if !shouldCompleteTransition || gestureRecognizer.state == .cancelled { - cancel() - } else { - finish() - } - default: - print("Swift switch must be exhaustive, thus the default") - } - } -} - -extension AKGInteractionAnimator : UIGestureRecognizerDelegate { - - private func gestureRecognizerShouldBegin(_ gestureRecognizer: UIPanGestureRecognizer) -> Bool { - let velocity : CGPoint = gestureRecognizer.velocity(in: gestureRecognizer.view) - return fabs(velocity.x) > fabs(velocity.y) && fabs(velocity.x) > 0; - } -} diff --git a/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift b/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift deleted file mode 100644 index f88159d..0000000 --- a/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift +++ /dev/null @@ -1,172 +0,0 @@ -// -// AKGPushAnimator.swift -// AKGPushAnimatorDemo -// -// Created by AHMET KAZIM GUNAY on 30/04/2017. -// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved. -// - -import UIKit - -@objc public protocol AKGPushAnimatorDelegate { - - @objc optional func beganTransition() - @objc optional func cancelledTransition() - @objc optional func finishedTransition() -} - -public class AKGPushAnimator: NSObject { - - public var isReverseTransition = false - - open var delegate : AKGPushAnimatorDelegate? - - // MARK: Variables with Getters - - var animatorScreenWidth : CGFloat { - get { - return UIScreen.main.bounds.width - } - } - - var animatorScreenHeight : CGFloat { - get { - return UIScreen.main.bounds.height - } - } - - var toViewPushedFrame : CGRect { - get { - return CGRect(x : 0, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - var fromViewPushedFrame : CGRect { - get { - return CGRect(x : AKGPushAnimatorConstants.Common.dismissPosition, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - var fromViewPopedFrame : CGRect { - get { - return CGRect(x : self.animatorScreenWidth, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - var toViewPopedFrame : CGRect { - get { - return CGRect(x : 0, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - fileprivate func animate(withTransitionContext transitionContext:UIViewControllerContextTransitioning, - toView: UIView, - fromView: UIView, - duration: TimeInterval, - delay: TimeInterval, - options: UIViewAnimationOptions = [], - animations: @escaping () -> Swift.Void) { - - UIView.animate(withDuration: duration, - delay: delay, - options: options, - animations: animations) { (finished) in - - if (transitionContext.transitionWasCancelled) { - toView.removeFromSuperview() - self.delegate?.cancelledTransition?() - } else { - fromView.removeFromSuperview() - self.delegate?.finishedTransition?() - } - transitionContext.completeTransition(!transitionContext.transitionWasCancelled) - - } - } - - fileprivate func addShadowToView(_ toView:UIView!) -> Swift.Void { - - toView.layer.shadowOpacity = AKGPushAnimatorConstants.Common.shadowOpacity - toView.layer.shadowOffset = CGSize(width:0, height:3) - toView.layer.shadowColor = AKGPushAnimatorConstants.Common.shadowColor.cgColor - let shadowRect: CGRect = toView.bounds.insetBy(dx: 0, dy: 4); // inset top/bottom - toView.layer.shadowPath = UIBezierPath(rect: shadowRect).cgPath - } -} - -extension AKGPushAnimator: UIViewControllerAnimatedTransitioning { - - // MARK: UIViewControllerAnimatedTransitioning - - public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { - return AKGPushAnimatorConstants.Common.duration - } - - public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { - - let containerView = transitionContext.containerView - - guard let toVC = transitionContext.viewController(forKey: .to), - let fromVC = transitionContext.viewController(forKey: .from), - let toView = toVC.view, - let fromView = fromVC.view else { return } - - addShadowToView(toView) - - delegate?.beganTransition?() - - if !isReverseTransition { - - containerView.addSubview(fromView) - containerView.addSubview(toView) - - toView.frame = CGRect(x : animatorScreenWidth, - y : toView.frame.origin.y, - width : animatorScreenWidth, - height : animatorScreenHeight) - - animate(withTransitionContext: transitionContext, - toView: toView, - fromView: fromView, - duration: AKGPushAnimatorConstants.Common.duration, - delay: 0, - options: AKGPushAnimatorConstants.Push.animateOption, - animations: { - fromView.frame = self.fromViewPushedFrame - toView.frame = self.toViewPushedFrame}) - } - else { - - containerView.addSubview(toView) - containerView.addSubview(fromView) - - toView.frame = CGRect(x : AKGPushAnimatorConstants.Common.dismissPosition, - y : toView.frame.origin.y, - width : animatorScreenWidth, - height : animatorScreenHeight) - - animate(withTransitionContext: transitionContext, - toView: toView, - fromView: fromView, - duration: AKGPushAnimatorConstants.Common.duration, - delay: 0, - options: AKGPushAnimatorConstants.Pop.animateOption, - animations: { - fromView.frame = self.fromViewPopedFrame - toView.frame = self.toViewPopedFrame }) - } - } -} - diff --git a/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift b/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift deleted file mode 100644 index eeec13f..0000000 --- a/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// AKGPushAnimatorConstants.swift -// AKGPushAnimatorDemo -// -// Created by AHMET KAZIM GUNAY on 30/04/2017. -// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved. -// - -import UIKit - -struct AKGPushAnimatorConstants { - - struct Common { - static let duration = 0.27 - static let dismissPosition : CGFloat = -50 - static let shadowOpacity : Float = 1 - static let shadowColor : UIColor = .black - } - - struct Push { - static let animateOption : UIViewAnimationOptions = .curveEaseOut - - } - - struct Pop { - static let animateOption : UIViewAnimationOptions = .curveEaseInOut - } -} diff --git a/Examples/AKGPushAnimatorDemo/AKGPushAnimator.xcodeproj/project.pbxproj b/Examples/AKGPushAnimatorDemo/AKGPushAnimator.xcodeproj/project.pbxproj index 6c33980..30bc630 100644 --- a/Examples/AKGPushAnimatorDemo/AKGPushAnimator.xcodeproj/project.pbxproj +++ b/Examples/AKGPushAnimatorDemo/AKGPushAnimator.xcodeproj/project.pbxproj @@ -16,9 +16,9 @@ C31058731EBF3C4800C18F16 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058701EBF3C4800C18F16 /* BaseViewController.swift */; }; C31058741EBF3C4800C18F16 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058711EBF3C4800C18F16 /* FirstViewController.swift */; }; C31058751EBF3C4800C18F16 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058721EBF3C4800C18F16 /* SecondViewController.swift */; }; - C310587A1EBF3C5100C18F16 /* AKGInteractionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */; }; - C310587B1EBF3C5100C18F16 /* AKGPushAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */; }; - C310587C1EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */; }; + C3634D4B1F153C1300DDF5B0 /* AKGInteractionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3634D481F153C1300DDF5B0 /* AKGInteractionAnimator.swift */; }; + C3634D4C1F153C1300DDF5B0 /* AKGPushAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3634D491F153C1300DDF5B0 /* AKGPushAnimator.swift */; }; + C3634D4D1F153C1300DDF5B0 /* AKGPushAnimatorConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3634D4A1F153C1300DDF5B0 /* AKGPushAnimatorConstants.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -69,9 +69,9 @@ C31058701EBF3C4800C18F16 /* BaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = ""; }; C31058711EBF3C4800C18F16 /* FirstViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = ""; }; C31058721EBF3C4800C18F16 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; - C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AKGInteractionAnimator.swift; sourceTree = ""; }; - C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AKGPushAnimator.swift; sourceTree = ""; }; - C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AKGPushAnimatorConstants.swift; sourceTree = ""; }; + C3634D481F153C1300DDF5B0 /* AKGInteractionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AKGInteractionAnimator.swift; path = ../../../Source/AKGInteractionAnimator.swift; sourceTree = ""; }; + C3634D491F153C1300DDF5B0 /* AKGPushAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AKGPushAnimator.swift; path = ../../../Source/AKGPushAnimator.swift; sourceTree = ""; }; + C3634D4A1F153C1300DDF5B0 /* AKGPushAnimatorConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AKGPushAnimatorConstants.swift; path = ../../../Source/AKGPushAnimatorConstants.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -123,7 +123,7 @@ C310582F1EBF3B3400C18F16 /* AKGPushAnimator */ = { isa = PBXGroup; children = ( - C31058761EBF3C5100C18F16 /* AKGPushAnimator */, + C3634D471F153C0800DDF5B0 /* Source */, C31058701EBF3C4800C18F16 /* BaseViewController.swift */, C31058711EBF3C4800C18F16 /* FirstViewController.swift */, C31058721EBF3C4800C18F16 /* SecondViewController.swift */, @@ -163,14 +163,14 @@ path = AKGPushAnimatorKit; sourceTree = ""; }; - C31058761EBF3C5100C18F16 /* AKGPushAnimator */ = { + C3634D471F153C0800DDF5B0 /* Source */ = { isa = PBXGroup; children = ( - C31058771EBF3C5100C18F16 /* AKGInteractionAnimator.swift */, - C31058781EBF3C5100C18F16 /* AKGPushAnimator.swift */, - C31058791EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift */, + C3634D481F153C1300DDF5B0 /* AKGInteractionAnimator.swift */, + C3634D491F153C1300DDF5B0 /* AKGPushAnimator.swift */, + C3634D4A1F153C1300DDF5B0 /* AKGPushAnimatorConstants.swift */, ); - path = AKGPushAnimator; + name = Source; sourceTree = ""; }; /* End PBXGroup section */ @@ -311,13 +311,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C310587B1EBF3C5100C18F16 /* AKGPushAnimator.swift in Sources */, - C310587A1EBF3C5100C18F16 /* AKGInteractionAnimator.swift in Sources */, C31058311EBF3B3400C18F16 /* AppDelegate.swift in Sources */, - C310587C1EBF3C5100C18F16 /* AKGPushAnimatorConstants.swift in Sources */, C31058731EBF3C4800C18F16 /* BaseViewController.swift in Sources */, C31058751EBF3C4800C18F16 /* SecondViewController.swift in Sources */, C31058741EBF3C4800C18F16 /* FirstViewController.swift in Sources */, + C3634D4D1F153C1300DDF5B0 /* AKGPushAnimatorConstants.swift in Sources */, + C3634D4C1F153C1300DDF5B0 /* AKGPushAnimator.swift in Sources */, + C3634D4B1F153C1300DDF5B0 /* AKGInteractionAnimator.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift b/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift deleted file mode 100644 index 7341e10..0000000 --- a/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGInteractionAnimator.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// AKGInteractionAnimator.swift -// AKGPushAnimatorDemo -// -// Created by AHMET KAZIM GUNAY on 30/04/2017. -// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved. -// - -import UIKit - -public class AKGInteractionAnimator: UIPercentDrivenInteractiveTransition { - - var navigationController: UINavigationController! - var shouldCompleteTransition = false - public var transitionInProgress = false - - public func attachToViewController(_ viewController: UIViewController) { - navigationController = viewController.navigationController - addGestureRecognizer(viewController.view) - } - - fileprivate func addGestureRecognizer(_ view: UIView) { - let panGesture = UIPanGestureRecognizer(target: self, action: #selector(AKGInteractionAnimator.handlePanGesture(_:))) - panGesture.delegate = self - view.addGestureRecognizer(panGesture) - } - - func handlePanGesture(_ gestureRecognizer: UIPanGestureRecognizer) { - let viewTranslation = gestureRecognizer.translation(in: gestureRecognizer.view?.superview) - let velocity : CGPoint = gestureRecognizer.velocity(in: gestureRecognizer.view) - - switch gestureRecognizer.state { - case .began: - transitionInProgress = true - navigationController.popViewController(animated: true) - case .changed: - var const = CGFloat(viewTranslation.x / UIScreen.main.bounds.width * 1.0) - const = min(1.0, max(0.0, const)) - shouldCompleteTransition = const > 0.5 || velocity.x > UIScreen.main.bounds.width - update(const) - case .cancelled, .ended: - transitionInProgress = false - if !shouldCompleteTransition || gestureRecognizer.state == .cancelled { - cancel() - } else { - finish() - } - default: - print("Swift switch must be exhaustive, thus the default") - } - } -} - -extension AKGInteractionAnimator : UIGestureRecognizerDelegate { - - private func gestureRecognizerShouldBegin(_ gestureRecognizer: UIPanGestureRecognizer) -> Bool { - let velocity : CGPoint = gestureRecognizer.velocity(in: gestureRecognizer.view) - return fabs(velocity.x) > fabs(velocity.y) && fabs(velocity.x) > 0; - } -} diff --git a/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift b/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift deleted file mode 100644 index f88159d..0000000 --- a/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimator.swift +++ /dev/null @@ -1,172 +0,0 @@ -// -// AKGPushAnimator.swift -// AKGPushAnimatorDemo -// -// Created by AHMET KAZIM GUNAY on 30/04/2017. -// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved. -// - -import UIKit - -@objc public protocol AKGPushAnimatorDelegate { - - @objc optional func beganTransition() - @objc optional func cancelledTransition() - @objc optional func finishedTransition() -} - -public class AKGPushAnimator: NSObject { - - public var isReverseTransition = false - - open var delegate : AKGPushAnimatorDelegate? - - // MARK: Variables with Getters - - var animatorScreenWidth : CGFloat { - get { - return UIScreen.main.bounds.width - } - } - - var animatorScreenHeight : CGFloat { - get { - return UIScreen.main.bounds.height - } - } - - var toViewPushedFrame : CGRect { - get { - return CGRect(x : 0, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - var fromViewPushedFrame : CGRect { - get { - return CGRect(x : AKGPushAnimatorConstants.Common.dismissPosition, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - var fromViewPopedFrame : CGRect { - get { - return CGRect(x : self.animatorScreenWidth, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - var toViewPopedFrame : CGRect { - get { - return CGRect(x : 0, - y : 0, - width : self.animatorScreenWidth, - height : self.animatorScreenHeight) - } - } - - fileprivate func animate(withTransitionContext transitionContext:UIViewControllerContextTransitioning, - toView: UIView, - fromView: UIView, - duration: TimeInterval, - delay: TimeInterval, - options: UIViewAnimationOptions = [], - animations: @escaping () -> Swift.Void) { - - UIView.animate(withDuration: duration, - delay: delay, - options: options, - animations: animations) { (finished) in - - if (transitionContext.transitionWasCancelled) { - toView.removeFromSuperview() - self.delegate?.cancelledTransition?() - } else { - fromView.removeFromSuperview() - self.delegate?.finishedTransition?() - } - transitionContext.completeTransition(!transitionContext.transitionWasCancelled) - - } - } - - fileprivate func addShadowToView(_ toView:UIView!) -> Swift.Void { - - toView.layer.shadowOpacity = AKGPushAnimatorConstants.Common.shadowOpacity - toView.layer.shadowOffset = CGSize(width:0, height:3) - toView.layer.shadowColor = AKGPushAnimatorConstants.Common.shadowColor.cgColor - let shadowRect: CGRect = toView.bounds.insetBy(dx: 0, dy: 4); // inset top/bottom - toView.layer.shadowPath = UIBezierPath(rect: shadowRect).cgPath - } -} - -extension AKGPushAnimator: UIViewControllerAnimatedTransitioning { - - // MARK: UIViewControllerAnimatedTransitioning - - public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { - return AKGPushAnimatorConstants.Common.duration - } - - public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { - - let containerView = transitionContext.containerView - - guard let toVC = transitionContext.viewController(forKey: .to), - let fromVC = transitionContext.viewController(forKey: .from), - let toView = toVC.view, - let fromView = fromVC.view else { return } - - addShadowToView(toView) - - delegate?.beganTransition?() - - if !isReverseTransition { - - containerView.addSubview(fromView) - containerView.addSubview(toView) - - toView.frame = CGRect(x : animatorScreenWidth, - y : toView.frame.origin.y, - width : animatorScreenWidth, - height : animatorScreenHeight) - - animate(withTransitionContext: transitionContext, - toView: toView, - fromView: fromView, - duration: AKGPushAnimatorConstants.Common.duration, - delay: 0, - options: AKGPushAnimatorConstants.Push.animateOption, - animations: { - fromView.frame = self.fromViewPushedFrame - toView.frame = self.toViewPushedFrame}) - } - else { - - containerView.addSubview(toView) - containerView.addSubview(fromView) - - toView.frame = CGRect(x : AKGPushAnimatorConstants.Common.dismissPosition, - y : toView.frame.origin.y, - width : animatorScreenWidth, - height : animatorScreenHeight) - - animate(withTransitionContext: transitionContext, - toView: toView, - fromView: fromView, - duration: AKGPushAnimatorConstants.Common.duration, - delay: 0, - options: AKGPushAnimatorConstants.Pop.animateOption, - animations: { - fromView.frame = self.fromViewPopedFrame - toView.frame = self.toViewPopedFrame }) - } - } -} - diff --git a/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift b/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift deleted file mode 100644 index eeec13f..0000000 --- a/Examples/AKGPushAnimatorDemo/AKGPushAnimator/AKGPushAnimator/AKGPushAnimatorConstants.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// AKGPushAnimatorConstants.swift -// AKGPushAnimatorDemo -// -// Created by AHMET KAZIM GUNAY on 30/04/2017. -// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved. -// - -import UIKit - -struct AKGPushAnimatorConstants { - - struct Common { - static let duration = 0.27 - static let dismissPosition : CGFloat = -50 - static let shadowOpacity : Float = 1 - static let shadowColor : UIColor = .black - } - - struct Push { - static let animateOption : UIViewAnimationOptions = .curveEaseOut - - } - - struct Pop { - static let animateOption : UIViewAnimationOptions = .curveEaseInOut - } -}