New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment overrides Style/onSetup(_:)
#96
Comments
The most straight forwards solution is to make DiffableTextStyles provide optional values for each environment value and then set values as |
Another option is to have styles transform the environment, rather than the view. Or transform a backup environment. |
I wish Apple would’ve commented on if you’re allowed to mutate the environment in |
I made my own environment in a small text-based side project, and it was implemented as a linked-list-esque-thing-y. In that case, it would’ve been fine to mutate it. SwiftUI’s environment seems link-y when using |
Hm. I think an environment approach only works if it is guaranteed that every environment value is optional… |
Another thing I’ve been thinking about is if it makes sense for styles to be the provider of this kind of behavior. I’m not sure styles should have any platform awareness. I’m inclined to say that it doesn’t make sense, considering how much time is spent on dependency cycles. The behavior it enables is 100% desirable, however. Smart views, best views. If there’s a way to set different defaults for DiffableTextField on [some platform, some tech] where [some style] then that would be more ideal, I think. |
I don’t see a solution that is maintainable/extensible enough to warrant deviating from standard SwiftUI behavior, so I will retire this feature for the time being. |
In v4.0.0+ it works like it does in SwiftUI. I thought it was rather neat, however, that NumberTextStyle could choose the correct keyboard automatically. So I will have to think about how I can reintroduce this feature, so it works alongside the environment.
The text was updated successfully, but these errors were encountered: