I'm working on a simple app (new to SwiftUI) and having some issues with the NavigationView element. I have added a NavigationView to my top-level view but this creates a block of blank space above the view that I can't seem to remove. If I take out the NavigationView the rest of the views display as expected. I have tried removing the navigation bar Title modifiers from deeper in the app but that also hasn't had any effect. I'm at a bit of a loss as to what is going on here ... have I made this too complicated for my own good? (images to illustrate the results)
Code for the view with the issue.
var body: some View {
NavigationView {
VStack{
todayView()
categoryList()
.padding(5)
Spacer()
}
}
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
initial navigationLinks are in the categoriesList (Red) which lead to a list of items also with navigationLinks (code below)
@EnvironmentObject var modelData: ModelData
@State private var showHotListOnly = false
var filteredHotTasks: [Task] {
modelData.tasks.filter { task in
(!showHotListOnly || task.isHotList)
}
}
var body: some View {
//NavigationView {
List {
ForEach(filteredHotTasks) { task in
NavigationLink(destination: TaskDetail(task: task)) {
TaskRow(task: task)
}
}
}
.navigationTitle(showHotListOnly ? "Hot List" : "Tasks")
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(trailing:
Button (action: {
showHotListOnly.toggle()
}) {
Image(systemName: showHotListOnly ? "flame.fill" : "flame")
.foregroundColor(showHotListOnly ? Color.orange : Color.gray)
}
)
//}
}
Any and all help greatly appreciated! Especially before I go bald from frustration.