I’m currently working on a to-do list app. When there are no to-dos, the used list-element shows a grey rectangle. Because that’s not very cute and expresses nothing, I have tried to figure out a workaround. Here’s the solution I have found:
// ...
if todos.count == 0 {
Text("Currently exist no to-dos")
Spacer()
} else {
List(todos) { todo in
NavigationLink {
Details(todo: todo)
} label: {
Text(todo.text ?? "")
}
}
}
// ...
Is there are a better way to deal with a list, when no list-items exist?