The "none" text representation for optional selections should be configurable.
Situation
Right now, in navigationLink style pickers, when an optional binding is given to selection and there is nothing selected, the choice is represented by the string "(None)". This is localizable, but not otherwise configurable.
Solution
There should be a way to configure how the "none" choice is represented, with "(None)" being default.
It should be configurable with some View with a convenience String option.
Dilemma
I'm not sure if these should be init parameters, or view modifiers though.
Init approach
For
- This is view content so seems more appropriate to pass into the init
Against
I'm hesitant to add more parameters to the init because:
- It strays farther from
SwiftUI.PickerAPI - and because the init already has two other view parameters in the init (the Label and content views), and the init might get pretty unwieldy with all these
ViewBuilderclosure parameters.
View Modifier approach
For
- Don't have to change the
initAPI - Can apply the configuration to multiple
MultiPickers
Against
But on the other hand:
- Creating more view modifiers that are only applicable to
MultiPicker - view modifiers that take view content seems like not purely configuration
This should be generalized as a choice representation style, .custom. that takes a closure that is passed a collection of choices, then the consumer can decide how they want that represented. Whether it's one, none, or multiple, they can do whatever they want.
Is this related to the issue I met that my app spams the following error after using this Swift Package?:
If so, please use Text(verbatim:) instead wherever appropriate.
@ShikiSuen thanks for reporting this. It looks like you're using NSShowNonLocalizedStrings. Using Text(verbatim:) would prevent library consumers from being able to localize this particular string. To get rid of the message, turn off NSShowNonLocalizedStrings, or add an entry for "(None)" in your Localized.strings or Localized.stringdict file. In the meantime, I'll see if there's a better way for me to do this than what I'm currently doing.
Thanks