swift-cross-ui
swift-cross-ui copied to clipboard
View/environment modifier, support for both EnvironmentValues and EnvironmentKey (used for custom storage in the environment)
This PR adds:
- EnvironmentValues/with(key:, value:) //equivalent to with(keyPath: newValue:) but for non-builtin values
- view modifiers for both builtin (key path) and not builtin (EnvironmentKey) values
For demonstration and testing purposes I changed GreetingGeneratorExample’s latest greeting display to get its value over an environment key.
The @Environment property wrapper was changed to additionally support EnvironmentKeys.
I did some limited testing which worked like expected. The modifiers just use the EnvironmentModifier View just like we do with most other modifiers.