Defining Custom Environment Keys in SwiftUI

When implementing apps using SwiftUI, we often need to access a view’s environment and read values from it. It’s easy to give environment a picture; think of it as a memory pool containing global values, shared and accessible all the way down to the view hierarchy.
SwiftUI framework sets several values to the environment by default. We can get them by declaring properties marked with the…