Skip to content

Commit

Permalink
TableView Demo Added
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetkgunay committed May 12, 2017
1 parent 74b1e88 commit 04bbe2b
Show file tree
Hide file tree
Showing 77 changed files with 4,985 additions and 0 deletions.
596 changes: 596 additions & 0 deletions Examples/AKGPushAnimatorDemo/AKGPushAnimator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C310582C1EBF3B3400C18F16"
BuildableName = "AKGPushAnimator.app"
BlueprintName = "AKGPushAnimator"
ReferencedContainer = "container:AKGPushAnimator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C31058401EBF3B3400C18F16"
BuildableName = "AKGPushAnimatorTests.xctest"
BlueprintName = "AKGPushAnimatorTests"
ReferencedContainer = "container:AKGPushAnimator.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C310584B1EBF3B3400C18F16"
BuildableName = "AKGPushAnimatorUITests.xctest"
BlueprintName = "AKGPushAnimatorUITests"
ReferencedContainer = "container:AKGPushAnimator.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C310582C1EBF3B3400C18F16"
BuildableName = "AKGPushAnimator.app"
BlueprintName = "AKGPushAnimator"
ReferencedContainer = "container:AKGPushAnimator.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C310582C1EBF3B3400C18F16"
BuildableName = "AKGPushAnimator.app"
BlueprintName = "AKGPushAnimator"
ReferencedContainer = "container:AKGPushAnimator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C310582C1EBF3B3400C18F16"
BuildableName = "AKGPushAnimator.app"
BlueprintName = "AKGPushAnimator"
ReferencedContainer = "container:AKGPushAnimator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// 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:
let const = CGFloat(viewTranslation.x / UIScreen.main.bounds.width)
shouldCompleteTransition = const > 0.4 || 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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
//
// AKGPushAnimator.swift
// AKGPushAnimatorDemo
//
// Created by AHMET KAZIM GUNAY on 30/04/2017.
// Copyright © 2017 AHMET KAZIM GUNAY. All rights reserved.
//

import UIKit

public class AKGPushAnimator: NSObject, UIViewControllerAnimatedTransitioning {

public var isReverseTransition = false

// 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)
}
}

// 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 }

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

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
})
}
}
}

private 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()
} else {
fromView.removeFromSuperview()
}
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// 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
}
}
Loading

0 comments on commit 04bbe2b

Please sign in to comment.