swift-cross-ui icon indicating copy to clipboard operation
swift-cross-ui copied to clipboard

View/environment modifier, support for both EnvironmentValues and EnvironmentKey (used for custom storage in the environment)

Open MiaKoring opened this issue 4 months ago • 0 comments

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.

MiaKoring avatar Nov 03 '25 15:11 MiaKoring