Add support for custom navigation title in SwiftUI#134
Closed
ChaosCoder wants to merge 1 commit into
Closed
Conversation
Owner
|
Hello Andreas, and thanks for coming back with more suggestions! This one is interesting, because it’s been requested once. It might have been for the UIKit view controller then, but I would make the same answer: to me, this doesn’t feel like a customization option worth adding. If we start having properties to customise aspects that essentially fall back directly to UIKit/SwiftUI properties, then I wouldn’t know where to stop. Subclassing/forking/etc a custom implementation seems like the right approach here. Can you share what you want to customise this title with? Maybe it’s more a matter of localization? Something else? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, it is not possible to override the navigation title of a SwiftUI view. Since it is a
struct, we cannot simply inherit from it and override the body.In this PR, we add the
navigationTitleas a property and allow it to be passed via various initializers. Because we pass a default value tonavigationTitlein every initializer, the code remains completely backward compatible.It would be beneficial to have this change for the UIKit variant as well, but there are many places where we would need to pass it. Therefore, I have decided to keep this PR for the SwiftUI world.