Skip to content

Commit

Permalink
Merge pull request #22 from erikdrobne/fix/navigation-bar-appearance
Browse files Browse the repository at this point in the history
Navigation bar visibility should be adjustable on init.
  • Loading branch information
erikdrobne authored Sep 23, 2023
2 parents 9375c0c + dc8ff6b commit af8a69c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/SwiftUICoordinator/Routing/NavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ public class NavigationController: UINavigationController {

// MARK: - Initialization

public convenience init() {
/// Initializes an instance of the class with optional customization for the navigation bar's visibility.
///
/// - Parameter isNavigationBarHidden: A Boolean value indicating whether the navigation bar should be hidden on the created instance.
/// If set to `true`, the navigation bar will be hidden. If set to `false`, the navigation bar will be displayed.
///
/// - Note: By default `isNavigationBarHidden` is set to `true`.
///
public convenience init(isNavigationBarHidden: Bool = true) {
self.init(nibName: nil, bundle: nil)

self.isNavigationBarHidden = isNavigationBarHidden
}

private override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
Expand Down
26 changes: 26 additions & 0 deletions Tests/SwiftUICoordinatorTests/NavigationControllerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// File.swift
//
//
// Created by Erik Drobne on 23/09/2023.
//

import Foundation

import Foundation
import XCTest
@testable import SwiftUICoordinator

@MainActor
final class NavigationControllerTests: XCTestCase {

func testNavigationBarIsHiddenByDefault() {
let navigationController = NavigationController()
XCTAssertTrue(navigationController.isNavigationBarHidden)
}

func testNavigationBarIsNotHidden() {
let navigationController = NavigationController(isNavigationBarHidden: false)
XCTAssertFalse(navigationController.isNavigationBarHidden)
}
}

0 comments on commit af8a69c

Please sign in to comment.