Adding optional @Bindings to SwiftUI views

SwiftUI gained a number of new view types at WWDC this year, one of them being DisclosureGroup. DisclosureGroup acts like an expandable cell, showing or hiding it's content based on it's disclosure state. One interesting aspect of this view is that it provides a number of initializers, some of which require an isExpanded binding, some of which don't. In other words, this isExpanded binding is optionally passed in when the view is initialized. In this post, Federico Zanetello shows us how we can add optional bindings to SwiftUI views, by creating his own version of the DisclosureGroup view.