Reputation: 310
I have a details screen and i want to display outside the list a Text()
view and then another List
, but when i adding the Text()
below and outside the List
i can't see the view
Part of my code:
var body: some View {
NavigationView {
List {
Button(action: {}, label: {
Text("Name: \(name)")
})
Button(action: {}, label: {
Text("Description: \(description)")
})
Button(action: {}, label: {
Text("Numerical Target: \(numTarget)")
})
Picker(selection: $numUnitIndex, label: Text("Numerical Unit: \(numUnit)")) {
ForEach(0 ..< units.count) {
Text(self.units[$0]).tag($0).foregroundColor(.blue)//.listRowInsets(EdgeInsets())
}
}.pickerStyle(MenuPickerStyle())
Button(action: {}, label: {
Text("Start date: \(startDate)")
})
Button(action: {}, label: {
Text("End date: \(endDate)")
})
Button(action: {}, label: {
Text("Category: \(category)")
})
Spacer()
}.onAppear() {
setPickerValue()
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("Goal Details")
.toolbar {
Button("Add Step") {
print("Help tapped!")
}
}
Text("Steps for this goal").background(Color.black).font(.system(size: 20))
}
}
}
struct GoalDetailsView_Previews: PreviewProvider {
static var previews: some View {
GoalDetailsView(id: "", authorId: "", name: "", description: "", startDate: "", endDate: "", numTarget: "", numUnit: "", category: "")
}
}
Upvotes: 0
Views: 42
Reputation: 88267
When you're placing more that one item inside NavigationView
you need to specify container(VStack
/HStack
/ZStack
) explicitly, like this:
NavigationView {
VStack {
List {
// content
}
Text("Steps for this goal").font(.system(size: 20))
}
}
Generally speaking, screen will be split into sections for each NavigationView
sibling up to a system specific limit. For iOS this limit is 1, which makes all other views disappear, on iPadOS and macOS the limit is higher
Upvotes: 1