DisclosureTableRow es una fila de una tabla que puede ocultar o mostrar otras filas con base en un control (un botón con forma de flecha).
struct ContentView: View {
@State private var selectedPeople = Set<Person.ID>()
@State private var people = [
Person(givenName: "Juan", familyName: "Chavez", emailAddress: "juanchavez@icloud.com"),
Person(givenName: "Mei", familyName: "Chen", emailAddress: "meichen@icloud.com"),
Person(givenName: "Tom", familyName: "Clark", emailAddress: "tomclark@icloud.com"),
Person(givenName: "Gita", familyName: "Kumar", emailAddress: "gitakumar@icloud.com")
]
@State private var expanded = false
var body: some View {
NavigationStack {
VStack {
Table(of: Person.self) {
TableColumn("Given Name", value: \.givenName)
TableColumn("Family Name", value: \.familyName)
TableColumn("E-Mail Address", value: \.emailAddress)
} rows: {
DisclosureTableRow(people[0], isExpanded: $expanded) {
TableRow(people[1])
TableRow(people[2])
}
TableRow(people[3])
}
}
}
}
}

Top comments (0)