Swiftpack.co - divadretlaw/SwiftUI-NavigationItem as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by divadretlaw.
divadretlaw/SwiftUI-NavigationItem v0.3.0
📲 Access NavigationItem in SwiftUI
⭐️ 1
🕓 1 year ago
iOS
.package(url: "https://github.com/divadretlaw/SwiftUI-NavigationItem.git", from: "v0.3.0")

NavigationItem for SwiftUI

Why

SwiftUI doesn't expose the UINavigationItem from the NavigationView but sometimes you might want to access it to set the prompt or the backButtonDisplayMode. With this modifier you can easily customize the UINavigationItem of your SwiftUI NavigationViews.

Usage

The .navigationItem modifier has to be applied to the NavigationItem (or NavigationStack, NavigationSplitView when using iOS 16+) because otherwise the Environment will not be applied to the NavigationLink destinations. On child views you can apply them anywhere just like .navigationTitle

NavigationView {
    // content
}
.navigationItem { navigationItem in
    // Customize the NavigationItem here
    navigationItem.prompt = "Enter information"
    navigationItem.backButtonDisplayMode = .generic
}

Install

SwiftPM

https://github.com/divadretlaw/SwiftUI-NavigationItem.git

License

See LICENSE

Copyright © 2022 David Walter (www.davidwalter.at)

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics