31.8 Working with DisclosureGroups
The DisclosureGroup view will be demonstrated within a new SwiftUI View file. To add this view, right-click on the Shared folder in the project navigator panel and select the New File… menu option. In the new file template dialog, select the SwiftUI View file option, click Next and name the file SettingsView before clicking on the Create button.
With the SettingsView.swift file loaded into the editor, make the following additions to add some custom views and state properties that will be used to simulate settings controls:
import SwiftUI
struct SettingsView: View {
@State private var hybridState: Bool = false
@State private var electricState: Bool = true
@State private var fuelCellState: Bool = false
@State private var inversionState: Bool = true
.
.
struct ColorControl: View {
&...