AcknowList icon indicating copy to clipboard operation
AcknowList copied to clipboard

Change Navigation Title in SwiftUI

Open M-I-N opened this issue 1 year ago • 2 comments

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 avatar Apr 13 '23 07:04 M-I-N

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")
        }
    }
}

M-I-N avatar Apr 13 '23 07:04 M-I-N

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

vtourraine avatar Apr 14 '23 19:04 vtourraine