Skip to content
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

Closed
oscbyspro opened this issue May 10, 2022 · 7 comments
Closed

Environment overrides Style/onSetup(_:) #96

oscbyspro opened this issue May 10, 2022 · 7 comments
Labels
no this will not be worked on

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented May 10, 2022

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.

@oscbyspro oscbyspro added the bug sum ting broke label May 10, 2022
@oscbyspro
Copy link
Owner Author

The most straight forwards solution is to make DiffableTextStyles provide optional values for each environment value and then set values as user ?? style ?? default. I do not know if there is a better alternative, however.

@oscbyspro
Copy link
Owner Author

oscbyspro commented May 10, 2022

Another option is to have styles transform the environment, rather than the view. Or transform a backup environment.

@oscbyspro
Copy link
Owner Author

oscbyspro commented May 10, 2022

I wish Apple would’ve commented on if you’re allowed to mutate the environment in updateUIView(_:,context:), or if it’s the worst idea ever. I'mma just guess that it's a bad idea, since I dunno.

@oscbyspro
Copy link
Owner Author

oscbyspro commented May 10, 2022

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 dump(_:) on it, but dunno. A backup style preferences environment is probably safer.

@oscbyspro
Copy link
Owner Author

oscbyspro commented May 10, 2022

Hm. I think an environment approach only works if it is guaranteed that every environment value is optional…

@oscbyspro
Copy link
Owner Author

oscbyspro commented May 11, 2022

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.

@oscbyspro
Copy link
Owner Author

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.

@oscbyspro oscbyspro added no this will not be worked on and removed bug sum ting broke labels May 11, 2022
@oscbyspro oscbyspro closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no this will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant