DaisukeNagata / SwiftUI2.0

3 stars 0 forks source link

Disclosuregroup #7

Open DaisukeNagata opened 4 years ago

DaisukeNagata commented 4 years ago

https://developer.apple.com/documentation/swiftui/disclosuregroup

スクリーンショット 2020-06-29 5 16 26
DaisukeNagata commented 4 years ago
import SwiftUI

struct ToggleStates {
    var oneIsOn: Bool = false
    var twoIsOn: Bool = true
}

struct ContentView: View {

    @State private var toggleStates = ToggleStates()
    @State private var topExpanded: Bool = true

    var body: some View {
        DisclosureGroup("Items", isExpanded: $topExpanded) {
            Toggle("Toggle 1", isOn: $toggleStates.oneIsOn)
            Toggle("Toggle 2", isOn: $toggleStates.twoIsOn)
            DisclosureGroup("Sub-items") {
                Text("Sub-item 1")
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}