Thanks for your reply. I have ended up going a different direction because I don't understand the way the layout is working in the background still (it might be nice to have a session where I can sketch something and ask an engineer how they would achieve it, but that's beyond the scope of this at the moment).
Here's the new form. I think this is much more concise, but I don't know how to pass the selected ballot as a binding in the inspector (see the portion marked with ***, as I have included the type that the Ballot Inspector requires, but not the variable because I don't know what goes there):
enum Section: String, Identifiable, CaseIterable {
case ballots
case candidates
var id: Section { self }
var systemImageName: String {
switch self {
case .ballots:
return "list.number"
case .candidates:
return "person.3.sequence.fill"
}
}
}
var body: some View {
TabView(selection: $selectedSection) {
ForEach(Section.allCases) { section in
Tab(section.rawValue.capitalized, systemImage: section.systemImageName, value: section) {
switch section {
case .ballots:
BallotListView(document: $document,
selectedBallotID: $selectedBallotID)
.listStyle(.sidebar)
.inspector(isPresented: .constant(true)) {
BallotEditor(ballot: ***BINDING<Election.Ballot>***, maxRank: document.election.candidates.count)
}
case .candidates:
Text("Candidates")
}
}
}
}
.tabViewStyle(.sidebarAdaptable)
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: