StanfordSpezi / Spezi

Open-source framework for rapid development of modern, interoperable digital health applications.
https://swiftpackageindex.com/StanfordSpezi/Spezi/documentation
MIT License
130 stars 10 forks source link

Introduce EnvironmentAccessible #89

Closed Supereg closed 8 months ago

Supereg commented 8 months ago

Introduce EnvironmentAccessible

:recycle: Current situation & Problem

As of right now, it is not easy to access a Component directly within your SwiftUI views. This approach is, e.g., used within SpeziStorage to make its API easy accessible. We introduce the EnvironmentAccessible protocol that allows a Module to be accessed from the environment just like an Observable. Further, we optimized @Modifier and @Model to allow for later initialization.

:gear: Release Notes

:books: Documentation

:white_check_mark: Testing

New functionality was tested.

:pencil: Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

codecov[bot] commented 8 months ago

Codecov Report

Merging #89 (c408115) into main (3c0a44e) will decrease coverage by 0.82%. The diff coverage is 60.61%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89/graphs/tree.svg?width=650&height=150&src=pr&token=KHU2K1HTAM&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi)](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ```diff @@ Coverage Diff @@ ## main #89 +/- ## ========================================== - Coverage 95.49% 94.67% -0.82% ========================================== Files 36 37 +1 Lines 665 693 +28 ========================================== + Hits 635 656 +21 - Misses 30 37 +7 ``` | [Files](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | Coverage Δ | | |---|---|---| | [...apabilities/Observable/EnvironmentAccessible.swift](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aS9DYXBhYmlsaXRpZXMvT2JzZXJ2YWJsZS9FbnZpcm9ubWVudEFjY2Vzc2libGUuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...pabilities/ViewModifier/ViewModifierProvider.swift](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aS9DYXBhYmlsaXRpZXMvVmlld01vZGlmaWVyL1ZpZXdNb2RpZmllclByb3ZpZGVyLnN3aWZ0) | `100.00% <100.00%> (ø)` | | | [Sources/Spezi/Spezi/Spezi.swift](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aS9TcGV6aS9TcGV6aS5zd2lmdA==) | `95.24% <100.00%> (+0.65%)` | :arrow_up: | | [...ilities/ViewModifier/ModifierPropertyWrapper.swift](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aS9DYXBhYmlsaXRpZXMvVmlld01vZGlmaWVyL01vZGlmaWVyUHJvcGVydHlXcmFwcGVyLnN3aWZ0) | `68.00% <50.00%> (+14.67%)` | :arrow_up: | | [...Capabilities/Observable/ModelPropertyWrapper.swift](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aS9DYXBhYmlsaXRpZXMvT2JzZXJ2YWJsZS9Nb2RlbFByb3BlcnR5V3JhcHBlci5zd2lmdA==) | `53.58% <41.67%> (-7.53%)` | :arrow_down: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Last update [3c0a44e...c408115](https://app.codecov.io/gh/StanfordSpezi/Spezi/pull/89?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi).
Supereg commented 8 months ago

@PSchmiedmayer feel free to merge, once reviewed. Diff coverage is of due to the error state handling having high impact on the overall little diff