Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Gallet committed Jan 6, 2021
2 parents e4e121b + ddcc6cb commit d5f3a8e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ADNavigationBarExtension.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'ADNavigationBarExtension'
s.version = '1.0.1'
s.version = '1.0.2'
s.author = 'Fabernovel Technologies'
s.homepage = 'https://technologies.fabernovel.com/'
s.summary = 'ADNavigationBarExtension is a UI library written in Swift to show and hide an extension to your UINavigationBar'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.0.2]

### Fix
- Fix misplacement of navigation bar extension while hiding navigation bar (issue #5)

## [1.0.1]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// HideNavigationBarViewController.swift
// NavigationBarExtension_Example
//
// Created by Samuel Gallet on 06/01/2021.
// Copyright © 2021 CocoaPods. All rights reserved.
//

import ADUtils
import UIKit

class HideNavigationBarViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
let button = UIButton()
button.setTitle("back", for: .normal)
view.addSubview(button)
button.ad_centerInSuperview()
button.setTitleColor(.black, for: .normal)
button.addTarget(self, action: #selector(goBack), for: .primaryActionTriggered)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}

@objc private func goBack() {
navigationController?.popViewController(animated: true)
}
}
3 changes: 2 additions & 1 deletion Example/NavigationBarExtension/Step2ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Step2ViewController: UIViewController, UITableViewDataSource, UITableViewD
}

@objc private func nextStep() {

let viewController = HideNavigationBarViewController()
navigationController?.pushViewController(viewController, animated: true)
}
}

Expand Down
4 changes: 4 additions & 0 deletions NavigationBarExtension.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0C2A0B6925A5B0E500787D43 /* HideNavigationBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C2A0B6825A5B0E500787D43 /* HideNavigationBarViewController.swift */; };
0C39B59723E1E845004B0288 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 0C39B59423E1E845004B0288 /* LICENSE */; };
0C39B59823E1E845004B0288 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 0C39B59523E1E845004B0288 /* README.md */; };
0C39B59923E1E845004B0288 /* ADNavigationBarExtension.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 0C39B59623E1E845004B0288 /* ADNavigationBarExtension.podspec */; };
Expand Down Expand Up @@ -38,6 +39,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0C2A0B6825A5B0E500787D43 /* HideNavigationBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideNavigationBarViewController.swift; sourceTree = "<group>"; };
0C39B59423E1E845004B0288 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
0C39B59523E1E845004B0288 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
0C39B59623E1E845004B0288 /* ADNavigationBarExtension.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ADNavigationBarExtension.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
Expand Down Expand Up @@ -122,6 +124,7 @@
0C9C511C23E16C6E001A15F5 /* Step2ViewController.swift */,
0C9C511E23E16C88001A15F5 /* CountriesViewController.swift */,
0C9C512023E16CBA001A15F5 /* Stepper.swift */,
0C2A0B6825A5B0E500787D43 /* HideNavigationBarViewController.swift */,
);
name = "Example for NavigationBarExtension";
path = Example/NavigationBarExtension;
Expand Down Expand Up @@ -366,6 +369,7 @@
0C9C511723E16BEA001A15F5 /* StepView.swift in Sources */,
0C9C511923E16C10001A15F5 /* NavBarExtensionView.swift in Sources */,
0C9C511F23E16C88001A15F5 /* CountriesViewController.swift in Sources */,
0C2A0B6925A5B0E500787D43 /* HideNavigationBarViewController.swift in Sources */,
0CD9858E23D732B90035506B /* SwitchExtensionTableViewController.swift in Sources */,
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
0C9C511B23E16C37001A15F5 /* Step1ViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,19 @@ public class ExtensibleNavigationBarNavigationController: UINavigationController
viewController.additionalSafeAreaInsets = extensionAdditionalSafeAreaInsets
}

public override func setNavigationBarHidden(_ hidden: Bool, animated: Bool) {
super.setNavigationBarHidden(hidden, animated: animated)
resetExtensionContainerBottomConstraint()
}

// MARK: - Private

private func setup() {
delegate = self
navigationBar.setBackgroundImage(UIImage(), for: .default)
view.addSubview(navBarExtensionContainerView)
navBarExtensionContainerView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
navBarExtensionContainerBottomConstraint = navBarExtensionContainerView.bottomAnchor
.constraint(equalTo: navigationBar.bottomAnchor, constant: navigationBarAdditionalSize)
navBarExtensionContainerBottomConstraint?.isActive = true
resetExtensionContainerBottomConstraint()
navBarExtensionContainerView.ad_pinToSuperview(edges: [.left, .right])
view.bringSubviewToFront(navigationBar)
}
Expand Down Expand Up @@ -191,6 +194,13 @@ public class ExtensibleNavigationBarNavigationController: UINavigationController
navigationBar.shadowImage = needsToShowExtension ? UIImage() : nil
}
}

private func resetExtensionContainerBottomConstraint() {
NSLayoutConstraint.deactivate(navBarExtensionContainerBottomConstraint.map { [$0] } ?? [])
navBarExtensionContainerBottomConstraint = navBarExtensionContainerView.bottomAnchor
.constraint(equalTo: navigationBar.bottomAnchor, constant: navigationBarAdditionalSize)
navBarExtensionContainerBottomConstraint?.isActive = true
}
}

extension ExtensibleNavigationBarNavigationController: UINavigationControllerDelegate {
Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- ADNavigationBarExtension (1.0.1):
- ADNavigationBarExtension (1.0.2):
- ADUtils (~> 11.0)
- ADUtils (11.0.0):
- ADUtils/objc (= 11.0.0)
Expand All @@ -23,7 +23,7 @@ EXTERNAL SOURCES:
:path: "./"

SPEC CHECKSUMS:
ADNavigationBarExtension: 0919d4229f2de09054d022abfdb81812857408fe
ADNavigationBarExtension: f7f791cbad7ca548cf007f582e3d12907583f109
ADUtils: 5f5f1ad7a097dcf7104f9c160bc23a30d7943eb8
SwiftLint: 22ccbbe3b8008684be5955693bab135e0ed6a447

Expand Down

0 comments on commit d5f3a8e

Please sign in to comment.