vtourraine / AcknowList

Acknowledgements screen displaying a list of licenses, for example from CocoaPods and Swift Package Manager dependencies.
MIT License
784 stars 59 forks source link

Change Navigation Title in SwiftUI #109

Open M-I-N opened 1 year ago

M-I-N commented 1 year ago

In SwiftUI there is no straightforward way to customize the title for the Acknowledgment List view. It would be nice to have an option to pass in the navigation title.

M-I-N commented 1 year ago

For now, one hacky way is to provide a .toolbar along with the AcknowListSwiftUIView at the time of setting it up as a destination of a NavigationLink.

Here is a sample:

struct ContentView: View {
    var body: some View {
        NavigationStack {
            VStack {
                NavigationLink("Show Acknowledgements") {
                    AcknowListSwiftUIView(acknowledgements: [])
                        .toolbar {
                            ToolbarItem(placement: .principal) {
                                Text("3rd Party Libraries")
                            }
                        }
                }
            }
            .navigationTitle("My App")
        }
    }
}
vtourraine commented 1 year ago

That’s a very good observation. Anyone got a suggestion on how to address it?