StanfordSpezi / SpeziAccount

The Spezi Account module to enable login and signup functionality
https://swiftpackageindex.com/StanfordSpezi/SpeziAccount/documentation/
MIT License
5 stars 5 forks source link

Investigate usage of SwiftUI Preferences #20

Closed Supereg closed 10 months ago

Supereg commented 1 year ago

Problem

Currently, we rely on custom built mechanics to pass data up the SwiftUI View hierarchy (e.g. for Validation and for data collected in Signup and Overview views).

Solution

SwiftUI has a dedicated mechanism to pass data up the view hierarchy using Preferences.

We should investigate how we could simplify the current infrastructure by using SwiftUI Preferences. This includes the following actions points:

  1. One could replace the ValidationEngines type and introduce a mechanism for ValidationEngines to pass up a submit validation hook (e.g. a view having a submit/save/done button could collect these closures/or validation engine from it's subviews).
  2. DataEntry views could pass up their input values using preferences. Though not sure if they are considered a "preference"(?).

Additional context

No response

Code of Conduct

Supereg commented 10 months ago

Validation logic was moved out into SpeziValidation. See #35. PreferenceKeys were considered as a core mechanisms to move state around the view hierarchy.