Last active
June 30, 2020 02:07
-
-
Save prafullakumar/7b13b5c090e3573b781e6de8d09fdce0 to your computer and use it in GitHub Desktop.
ios -14 Collapsible List
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Prafulla Singh on 29/6/20. | |
// | |
import SwiftUI | |
struct FamilyTree: Identifiable { | |
let id = UUID() | |
let name: String | |
let childrens: [FamilyTree]? | |
} | |
func generateData() -> [FamilyTree] { | |
return [FamilyTree.init(name: "A", childrens: [FamilyTree.init(name: "Aa", childrens: nil)]), FamilyTree.init(name: "B", childrens: [FamilyTree.init(name: "BB", childrens: nil)])] | |
} | |
struct DemoCollapsibleVIew: View { | |
let familyTreeRoot = generateData() | |
var body: some View { | |
List(familyTreeRoot, children: \.childrens) { familyTree in | |
Text(familyTree.name) | |
} | |
} | |
} | |
struct DemoCollapsibleVIew_Previews: PreviewProvider { | |
static var previews: some View { | |
DemoCollapsibleVIew() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment