I have a simple view in my app that displays a list of checklists. When there are no checklists I display a placeholder view.
The issue I'm having is that when I delete the last item in the list, the EditButton() doesn't switch back to "Edit"; it still says "Done," even thought the list is empty If I then add a new item, the list appears again but in edit mode (a bad UX).
Is there a way to manually "turn off" edit mode after the last item in the list gets deleted?
Image:https://i.stack.imgur.com/lE1yu.png
import SwiftUIstruct HomeView: View { // MARK: - PROPERTIES @EnvironmentObject var checklistsVM: Store @StateObject var homeVM: HomeViewModel = HomeViewModel() // MARK: - BODY var body: some View { NavigationView { Group { if(checklistsVM.checklists.isEmpty) { EmptyList() .environmentObject(homeVM) } else { HomeListResults() .environmentObject(homeVM) } } .navigationBarTitle("Checklists", displayMode: .large) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } } } .navigationViewStyle(StackNavigationViewStyle()) }}