2022-11-18 Example of hierarchical list

I actually didn't know that the SwiftUI List element natively supports hierarchical lists, until someone on Reddit asked for an example. Here's mine:

    struct Park: Identifiable {
        let id = UUID()
        let name: String
        let children: [Park]?
    }
    struct ContentView: View {
        private let parks = [
            Park(name: "Sierra Nevada", children: [
                Park(name: "Yosemite", children: [
                    Park(name: "Mount Dana", children: nil),
                    Park(name: "Mount Lyell", children: nil),
                ]),
                Park(name: "Stanislaus National Forest", children: [
                    Park(name: "Emigrant Wilderniss", children: nil),
                    Park(name: "Carson-Iceberg Wilderniss", children: nil),
                ])
            ])
        ]
        var body: some View {
            List(parks, children: \.children, rowContent: { Text($0.name) })
        }
    }