Skip to content

Commit 38d5247

Browse files
committed
- Initial commit for Example project
1 parent 69a14ef commit 38d5247

File tree

102 files changed

+9800
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+9800
-0
lines changed

ExampleGobstonesSwift/GobstonesSwift.xcodeproj/project.pbxproj

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

ExampleGobstonesSwift/GobstonesSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ExampleGobstonesSwift/GobstonesSwift.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Nishant Bhasin. <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// BottomUpTransition.swift
3+
//
4+
// The MIT License (MIT)
5+
//
6+
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
import Foundation
27+
import UIKit
28+
29+
class BottomUpTransition: NSObject, UIViewControllerAnimatedTransitioning {
30+
31+
let transitionDuration: TimeInterval = 0.6
32+
33+
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
34+
return transitionDuration
35+
}
36+
37+
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
38+
let container = transitionContext.containerView
39+
guard
40+
41+
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
42+
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
43+
else {
44+
transitionContext.completeTransition(true)
45+
return
46+
}
47+
48+
toView.frame = container.frame
49+
toView.frame.origin.y = container.frame.maxY
50+
container.addSubview(toView)
51+
52+
UIView.animate(
53+
withDuration: transitionDuration,
54+
animations: {
55+
fromViewController.view.frame.origin.y = -container.frame.maxY
56+
toView.frame = container.frame
57+
},
58+
completion: { _ in
59+
transitionContext.completeTransition(true)
60+
}
61+
)
62+
}
63+
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// FadeInTransition.swift
3+
//
4+
// The MIT License (MIT)
5+
//
6+
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
27+
import Foundation
28+
import UIKit
29+
30+
31+
class FadeInTransition: NSObject, UIViewControllerAnimatedTransitioning {
32+
33+
let transitionDuration: TimeInterval = 1.0
34+
35+
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
36+
return transitionDuration
37+
}
38+
39+
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
40+
let container = transitionContext.containerView
41+
guard
42+
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
43+
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
44+
else {
45+
transitionContext.completeTransition(true)
46+
return
47+
}
48+
49+
toView.frame = container.frame
50+
toView.alpha = 0.0
51+
container.addSubview(toView)
52+
53+
UIView.animate(
54+
withDuration: transitionDuration,
55+
animations: {
56+
toView.alpha = 1.0
57+
},
58+
completion: { _ in
59+
transitionContext.completeTransition(true)
60+
}
61+
)
62+
}
63+
64+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// FadeOutTransition.swift
3+
//
4+
// The MIT License (MIT)
5+
//
6+
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
import Foundation
27+
import UIKit
28+
29+
class SlideOutTransition: NSObject, UIViewControllerAnimatedTransitioning {
30+
31+
let transitionDuration: TimeInterval = 1.0
32+
33+
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
34+
return transitionDuration
35+
}
36+
37+
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
38+
let container = transitionContext.containerView
39+
guard
40+
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
41+
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
42+
else {
43+
transitionContext.completeTransition(true)
44+
return
45+
}
46+
47+
toView.frame = container.frame
48+
toView.alpha = 1.0
49+
container.addSubview(toView)
50+
51+
UIView.animate(
52+
withDuration: transitionDuration,
53+
animations: {
54+
toView.alpha = 0.0
55+
},
56+
completion: { _ in
57+
transitionContext.completeTransition(true)
58+
}
59+
)
60+
}
61+
62+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//
2+
// TopDownTransition.swift
3+
//
4+
// The MIT License (MIT)
5+
//
6+
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
import Foundation
27+
import UIKit
28+
29+
class TopDownTransition: NSObject, UIViewControllerAnimatedTransitioning {
30+
31+
let transitionDuration: TimeInterval = 0.5
32+
33+
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
34+
return transitionDuration
35+
}
36+
37+
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
38+
let container = transitionContext.containerView
39+
guard
40+
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to),
41+
let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
42+
else {
43+
transitionContext.completeTransition(true)
44+
return
45+
}
46+
47+
toView.frame = container.frame
48+
toView.frame.origin.y = -toView.frame.maxY
49+
container.addSubview(toView)
50+
51+
UIView.animate(
52+
withDuration: transitionDuration,
53+
animations: {
54+
fromViewController.view.frame.origin.y = container.frame.maxY
55+
toView.frame = container.frame
56+
},
57+
completion: { _ in
58+
transitionContext.completeTransition(true)
59+
}
60+
)
61+
}
62+
63+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// FadeInTransition.swift
3+
//
4+
// The MIT License (MIT)
5+
//
6+
// Copyright (c) 2016 Nishant Bhasin. <[email protected]>
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
import UIKit
27+
28+
class NBNavigationController: NSObject {
29+
30+
var customTransition: UIViewControllerAnimatedTransitioning?
31+
fileprivate weak var previousDelegate: UINavigationControllerDelegate?
32+
33+
func pushViewController(_ controller: UIViewController, ontoNavigationController navigationController: UINavigationController, animatedTransition: UIViewControllerAnimatedTransitioning) {
34+
self.previousDelegate = navigationController.delegate
35+
self.customTransition = animatedTransition
36+
navigationController.delegate = self
37+
navigationController.pushViewController(controller, animated: true)
38+
}
39+
40+
func popNavigationController(_ navigationController: UINavigationController, animatedTransition: UIViewControllerAnimatedTransitioning) {
41+
self.previousDelegate = navigationController.delegate
42+
self.customTransition = animatedTransition
43+
navigationController.delegate = self
44+
navigationController.popViewController(animated: true)
45+
}
46+
}
47+
48+
// MARK: - UINavigationControllerDelegate Extension
49+
50+
extension NBNavigationController: UINavigationControllerDelegate{
51+
52+
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
53+
return self.customTransition
54+
}
55+
56+
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
57+
navigationController.delegate = previousDelegate
58+
previousDelegate = nil
59+
}
60+
}
61+

0 commit comments

Comments
 (0)