Created
July 28, 2023 02:55
-
-
Save JustinFincher/a2d64d6d52535de7e3d841e7333230aa to your computer and use it in GitHub Desktop.
Recursive Outline Table
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
import SwiftUI | |
struct TestModel: Identifiable { | |
let id = UUID() | |
var children: [TestModel]? { | |
(0..<5).map { _ in | |
TestModel() | |
} | |
} | |
} | |
struct ContentView: View { | |
@State var root: TestModel = .init() | |
var body: some View { | |
Table(of: TestModel.self) { | |
TableColumn("ID", value: \.id.uuidString) | |
} rows: { | |
OutlineGroup(root, children: \.children) { row in | |
TableRow(row) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment