/NavFlow

It is a Swift Package that you can create any SwiftUI view as a navigation bar with your wishing height.

Primary LanguageSwift

NavFlow

NavFlow is a Swift Package that provides customizable navigation containers and navigation bars for SwiftUI applications. You can easily create your view a navigation bar and use it with either push or sheet navigation flows.

Overview

Navigation bar screenshots designed with NavFlow

Screenshot 1 Screenshot 4 Screenshot 2 Screenshot 5

✨ Features

  • πŸš€ Custom Navigation Bar β€” Provide any SwiftUI view as a navigation bar.
  • πŸ“± iOS Support β€” Includes UIKit-based navigation bar height calculation.
  • πŸ”„ Push & Sheet Navigation β€” Works with both NavigationLink and .sheet.
  • πŸ“ Dynamic or Standard Height β€” Use StandardNavigationHeight or DynamicNavigationHeight.

πŸ“¦ Installation

Swift Package Manager (SPM)

In Xcode: Go to File β†’ Add Packages… and enter the repo URL:

https://github.com/TolgaTaner/NavFlow.git

Or add it directly to your Package.swift:

dependencies: [
    .package(url: "https://github.com/TolgaTaner/NavFlow.git", from: "1.2.4")
]

πŸ”§ Usage

import NavFlow
import SwiftUI

struct ContentView: View {
 @State private var navigationPath = NavigationPath()

 var body: some View {
     NavFlowNavigationBarView(
         path: $navigationPath,
         backgroundColor: .blue,
         navigationBarHeight: StandardNavigationHeight()
     ) {
        /// Custom View For Navigation Bar
         HStack {
             Text("Back").foregroundColor(.white)
             Spacer()
             Text("Home").bold().foregroundColor(.white)
             Spacer()
             Button("Edit") { /* action */ }.foregroundColor(.white)
         }
     } content: {
         VStack {
             Text("Main content here")
                 .padding()
         }
     }
 }
}

Push Navigation

import SwiftUI
import NavFlow

struct PushExampleView: View {
    var body: some View {
        NavFlowNavigationPushLink(
            color: .blue,
            navigationHeight: StandardNavigationHeight(),
            navigationBarView: {
                HStack {
                    Text("Custom Nav")
                        .bold()
                        .foregroundColor(.white)
                    Spacer()
                    Button("Action") { /* do something */ }
                        .foregroundColor(.white)
                }
            },
            destination: Text("Destination Page")
        ) {
            Text("Go to Destination")
                .padding()
                .background(Color.gray.opacity(0.2))
                .cornerRadius(8)
        }
    }
}

Sheet Navigation

NavFlowNavigationSheetLink(
    color: .purple,
    navigationBarView: {
        Text("Sheet View").foregroundColor(.white)
    },
    destination: Text("This is a sheet")
) {
    Text("Open Sheet")
        .padding()
        .background(Color.gray.opacity(0.2))
        .cornerRadius(8)
}

πŸ“ Navigation Bar Height

NavFlow manages bar height through the NavigationBarHeight protocol.

Standard Height (status bar + nav bar, notch-aware):

let height = StandardNavigationHeight()

Custom Dynamic Height:

let customHeight = DynamicNavigationHeight(value: 100)

Hiding Navigation Bar:

If you want, you can hide navigation bar, but you can still use its features.

NavFlowNavigationBarView(
    backgroundColor: .black,
    navigationBarHeight: StandardNavigationHeight(),
    navigationBarView: { CustomBar() },
    content: { OnboardingView() }
)
.hideNavFlowNavigationBar()

πŸ›  Requirements iOS 16+ Swift 5.9+

πŸ“„ License MIT License