Swiftui Sheet Not Animating Dismissal on MACos Big Sur

SwiftUI sheet not animating dismissal on macOS Big Sur

I finally figured out how to do it, in my SwiftUI app it works if I do this while closing the sheet:

isSheetVisible = false
NSApp.mainWindow?.endSheet(NSApp.keyWindow!)

Example:

struct SheetView: View {
@Binding var isSheetVisible: Bool

var body: some View {
Button("Close") {
isSheetVisible = false
NSApp.mainWindow?.endSheet(NSApp.keyWindow!)
}
}
}

Working

Searchbar to filter contents on a list (macOS Big Sur)

Here's the answer edited to so people don't complain:

var body: some View {
NavigationView {
List(data.notes.filter { searchText.isEmpty ? true : $0.text.localizedCaseInsensitiveContains(searchText) }) { note in
NavigationLink(
destination: NoteView(note: note, text: note.text),
tag: note.id,
selection: $selectedNoteId
) {
VStack(alignment: .leading) {
Text(getTitle(noteText: note.text)).font(.body).fontWeight(.bold)
Text(note.dateText).font(.body).fontWeight(.light)
}
.padding(.vertical, 10)
}
}
.listStyle(InsetListStyle())
.frame(minWidth: 250, maxWidth: .infinity)
.alert(isPresented: $showAlert, content: {
alert
})

}


Related Topics



Leave a reply



Submit