-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Initial commit for Example project
- Loading branch information
Showing
102 changed files
with
9,800 additions
and
0 deletions.
There are no files selected for viewing
888 changes: 888 additions & 0 deletions
888
ExampleGobstonesSwift/GobstonesSwift.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
ExampleGobstonesSwift/GobstonesSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
ExampleGobstonesSwift/GobstonesSwift.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
ExampleGobstonesSwift/GobstonesSwift/Animation/LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
64 changes: 64 additions & 0 deletions
64
ExampleGobstonesSwift/GobstonesSwift/Animation/Transition/BottomUpTransition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
ExampleGobstonesSwift/GobstonesSwift/Animation/Transition/FadeInTransition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
ExampleGobstonesSwift/GobstonesSwift/Animation/Transition/FadeOutTransition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
ExampleGobstonesSwift/GobstonesSwift/Animation/Transition/TopDownTransition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
...eGobstonesSwift/GobstonesSwift/Animation/TrasitionController/NBNavigationController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|
Oops, something went wrong.