Skip to content

Commit bb2e3e2

Browse files
committed
- Cleanup and adding pod spec
1 parent 38d5247 commit bb2e3e2

File tree

9 files changed

+360
-7
lines changed

9 files changed

+360
-7
lines changed

ExampleGobstonesSwift/GobstonesSwift.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
8A37585A1E0B31360036E11B /* GobstonesSwiftUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GobstonesSwiftUITests.swift; sourceTree = "<group>"; };
7373
8A37585C1E0B31360036E11B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7474
8A3758751E0B383A0036E11B /* InitialViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InitialViewController.xib; sourceTree = "<group>"; };
75-
8A3758771E0B38460036E11B /* InitialViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InitialViewController.swift; sourceTree = "<group>"; };
75+
8A3758771E0B38460036E11B /* InitialViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InitialViewController.swift; path = ../ViewControllers/InitialViewController.swift; sourceTree = "<group>"; };
7676
8A3758791E0B3AEC0036E11B /* InitialViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InitialViewCell.swift; sourceTree = "<group>"; };
7777
8A37587B1E0B3AF80036E11B /* InitialViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InitialViewCell.xib; sourceTree = "<group>"; };
7878
8A3758821E0B5DDC0036E11B /* NetworkUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkUtils.swift; sourceTree = "<group>"; };
@@ -259,7 +259,6 @@
259259
isa = PBXGroup;
260260
children = (
261261
8A3758811E0B5DCD0036E11B /* BaseViewController */,
262-
8A3758771E0B38460036E11B /* InitialViewController.swift */,
263262
8A3758751E0B383A0036E11B /* InitialViewController.xib */,
264263
8AAFB0121E13685600989264 /* GifViewController */,
265264
);
@@ -269,6 +268,7 @@
269268
8A3758721E0B32CF0036E11B /* Views */ = {
270269
isa = PBXGroup;
271270
children = (
271+
8A3758771E0B38460036E11B /* InitialViewController.swift */,
272272
8A37588E1E0B78550036E11B /* CustomNavBar.swift */,
273273
8A37588F1E0B78550036E11B /* CustomNavBar.xib */,
274274
);

ExampleGobstonesSwift/GobstonesSwift/Info.plist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>NSAppTransportSecurity</key>
6-
<dict>
7-
<key>NSAllowsArbitraryLoads</key>
8-
<true/>
9-
</dict>
105
<key>CFBundleDevelopmentRegion</key>
116
<string>en</string>
127
<key>CFBundleExecutable</key>
@@ -25,6 +20,11 @@
2520
<string>1</string>
2621
<key>LSRequiresIPhoneOS</key>
2722
<true/>
23+
<key>NSAppTransportSecurity</key>
24+
<dict>
25+
<key>NSAllowsArbitraryLoads</key>
26+
<true/>
27+
</dict>
2828
<key>UILaunchStoryboardName</key>
2929
<string>LaunchScreen</string>
3030
<key>UIRequiredDeviceCapabilities</key>

LICENSE.txt

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.

NBNavigationController.podspec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'NBNavigationController'
3+
s.version = '0.1'
4+
s.summary = 'Navigation controller with custom transition'
5+
6+
s.description = <<-DESC
7+
This NBNavigationController supports custom transition.
8+
DESC
9+
10+
s.homepage = 'https://github.com/nbhasin2/NBNavigationController'
11+
s.license = { :type => 'MIT', :file => 'LICENSE' }
12+
s.author = { 'Nishant Bhasin' => '[email protected]' }
13+
s.source = { :git => 'https://github.com/nbhasin2/NBNavigationController.git', :tag => s.version.to_s }
14+
15+
s.ios.deployment_target = '10.0'
16+
s.source_files = 'NBNavigationController/*.swift'
17+
18+
end
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: 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)