Skip to content

Commit

Permalink
- Initial commit for Example project
Browse files Browse the repository at this point in the history
  • Loading branch information
nbhasin2 committed Jan 1, 2017
1 parent 69a14ef commit 38d5247
Show file tree
Hide file tree
Showing 102 changed files with 9,800 additions and 0 deletions.
888 changes: 888 additions & 0 deletions ExampleGobstonesSwift/GobstonesSwift.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.

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

21 changes: 21 additions & 0 deletions ExampleGobstonesSwift/GobstonesSwift/Animation/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Nishant Bhasin. <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// BottomUpTransition.swift
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Foundation
import UIKit

class BottomUpTransition: NSObject, UIViewControllerAnimatedTransitioning {

let transitionDuration: TimeInterval = 0.6

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return transitionDuration
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView
guard

let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
else {
transitionContext.completeTransition(true)
return
}

toView.frame = container.frame
toView.frame.origin.y = container.frame.maxY
container.addSubview(toView)

UIView.animate(
withDuration: transitionDuration,
animations: {
fromViewController.view.frame.origin.y = -container.frame.maxY
toView.frame = container.frame
},
completion: { _ in
transitionContext.completeTransition(true)
}
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// FadeInTransition.swift
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.


import Foundation
import UIKit


class FadeInTransition: NSObject, UIViewControllerAnimatedTransitioning {

let transitionDuration: TimeInterval = 1.0

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return transitionDuration
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView
guard
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
else {
transitionContext.completeTransition(true)
return
}

toView.frame = container.frame
toView.alpha = 0.0
container.addSubview(toView)

UIView.animate(
withDuration: transitionDuration,
animations: {
toView.alpha = 1.0
},
completion: { _ in
transitionContext.completeTransition(true)
}
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// FadeOutTransition.swift
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Foundation
import UIKit

class SlideOutTransition: NSObject, UIViewControllerAnimatedTransitioning {

let transitionDuration: TimeInterval = 1.0

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return transitionDuration
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView
guard
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
else {
transitionContext.completeTransition(true)
return
}

toView.frame = container.frame
toView.alpha = 1.0
container.addSubview(toView)

UIView.animate(
withDuration: transitionDuration,
animations: {
toView.alpha = 0.0
},
completion: { _ in
transitionContext.completeTransition(true)
}
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// TopDownTransition.swift
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Foundation
import UIKit

class TopDownTransition: NSObject, UIViewControllerAnimatedTransitioning {

let transitionDuration: TimeInterval = 0.5

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return transitionDuration
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView
guard
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
else {
transitionContext.completeTransition(true)
return
}

toView.frame = container.frame
toView.frame.origin.y = -toView.frame.maxY
container.addSubview(toView)

UIView.animate(
withDuration: transitionDuration,
animations: {
fromViewController.view.frame.origin.y = container.frame.maxY
toView.frame = container.frame
},
completion: { _ in
transitionContext.completeTransition(true)
}
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// FadeInTransition.swift
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import UIKit

class NBNavigationController: NSObject {

var customTransition: UIViewControllerAnimatedTransitioning?
fileprivate weak var previousDelegate: UINavigationControllerDelegate?

func pushViewController(_ controller: UIViewController, ontoNavigationController navigationController: UINavigationController, animatedTransition: UIViewControllerAnimatedTransitioning) {
self.previousDelegate = navigationController.delegate
self.customTransition = animatedTransition
navigationController.delegate = self
navigationController.pushViewController(controller, animated: true)
}

func popNavigationController(_ navigationController: UINavigationController, animatedTransition: UIViewControllerAnimatedTransitioning) {
self.previousDelegate = navigationController.delegate
self.customTransition = animatedTransition
navigationController.delegate = self
navigationController.popViewController(animated: true)
}
}

// MARK: - UINavigationControllerDelegate Extension

extension NBNavigationController: UINavigationControllerDelegate{

func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return self.customTransition
}

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
navigationController.delegate = previousDelegate
previousDelegate = nil
}
}

Loading

0 comments on commit 38d5247

Please sign in to comment.