Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation bar visibility should be adjustable on init. #22

Merged
merged 7 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}