SwiftUI Preferences

Most data flow constructs in SwiftUI propagate data down the view tree. Preferences work in the opposite direction: passing data up the hierarchy. This makes them very powerful, both in ways that are fairly straightforward and by enabling more complex behavior. A preference is defined by two things: a default value, which is the value used when nothing writes an explicit value, and a reducer…