StanfordSpezi / SpeziTemplateApplication

Template application demonstrating the usage of the Stanford Spezi framework.
https://stanfordspezi.github.io/SpeziTemplateApplication
MIT License
97 stars 19 forks source link

Add Xcode Preview to All Views #23

Closed PSchmiedmayer closed 8 months ago

PSchmiedmayer commented 1 year ago

Problem

Currently some views in the template application crash due to missing environment objects and some views do not provide any previews for the views.

Solution

Add the corresponding environment objects to the views and children by using a mechanism like proposed in https://github.com/StanfordSpezi/Spezi/issues/63.

In addition, we should use the new Preview macro as introduced with Xcode 15/Swift 5.9.

Additional context

This issue requires a mechanism as described in https://github.com/StanfordSpezi/Spezi/issues/63 to make the injection of modules easy when working with Xcode previews. Feel free to discuss the implications and ideas for APIs in the StanfordSpezi/Spezi repository and help us to address this issue.

We would encourage anyone who wants to address this PR to first watch the WWDC23 - Build programmatic UI with Xcode Previews session to learn more about previews and the new macros.

Code of Conduct

Supereg commented 8 months ago

The mechanism described in https://github.com/StanfordSpezi/Spezi/issues/63 is finally supported and is now used with the latest changes in #60 .

PSchmiedmayer commented 8 months ago

Thank you @Supereg for the improvements!