I am trying to create a simple list view in SwiftUI however, it shows up as blank (pictured below) no matter how many objects are in the array. If I get rid of the list, it will show the elements of the array. I know for a fact that the array is not empty. Any recommendations on how to fix it.
This is my code"
var body: some View {
NavigationView {
ScrollView {
if(leaderboard.isEmpty) {
VStack {
Text("No Entries Yet :(")
.foregroundColor(.gray)
.font(.largeTitle)
}
} else {
ScrollView {
List {
ForEach(leaderboard.asArray(), id: \.self) { score in
Text("\(score)")
}
}
}
}
}
.navigationBarTitle("Leaderboard")
}
}
Here is what the view currently shows:

Also, bonus points if you can help me make it so the Text("No Entries Yet :( ") is centered vertically within the view.
ScrollViewif you are using aListScrollViewbecomes extremely tiny in height to the point where you can't see it. Remove bothScrollViews.