SlideOverCards being created indefinitely
Hi. I want to add this card to my application. I'm doing it like I do with a normal .sheet, but I don't know why it is creating cards like on an infinite loop.
Main view code:
@StateObject private var captureViewModel = CaptureViewModel()
var body: some View {
let filteredList = accounts.filter() {
if codesViewModel.searchText == "" {
return true
}
guard let item = $0.name else { return false }
return item.lowercased().contains(codesViewModel.searchText.lowercased())
}
NavigationView {
Group {
...
}
.toolbar(content: {
ToolbarItem(placement: .topBarTrailing) {
HStack {
Menu {
if (!ProcessInfo.processInfo.isMacCatalystApp) {
Button {
captureViewModel.sheetOpen.toggle() // Opens the slide over card (previously it was a sheet)
} label: {
Label("Capture QR code", systemImage: "qrcode.viewfinder")
}
}
...
} label: {
Image(systemName: "plus")
}
}
}
})
.slideOverCard(isPresented: $captureViewModel.sheetOpen) {
CaptureView(captureViewModel: captureViewModel)
}
.sheet(isPresented: $newAccountFormViewModel.sheetOpen, content: {
NewAccountFormViewIos(newAccountFormViewModel: newAccountFormViewModel)
})
.preferredColorScheme(appConfig.theme)
}
.navigationViewStyle(StackNavigationViewStyle())
}
The slide over view:
var body: some View {
Group {
...
}
.frame(height: 300)
.onAppear(perform: {
...
})
}
Hi @JGeek00! Thank you so much for pointing this out to me. I ran across this issue a few times but I thought I had handled all of the edge cases to fix it. I'll take a look later today!
Great! Let me know if you need more details.
Having the same issue! Also having a conditional view or animating the opacity of the view causes the new view to disappear and a new sheet to appear ex:
if isConnecting {
ProgressView()
}
or
.opacity(isPresented ? 1:0)
summons a new view or draws unlimited new cards
Any news regarding this issue @joogps ?
I'm seeing this too after upgrading to 3.0.1 from 2.1.0. I have a view that has isPresented fixed at true, so that the SlideOverCard is fixed in place. Any time I do a drag-from-bottom gesture as if switching apps, even if momentary, a new SlideOverCard with the same content slides up over the existing card. This will occur indefinitely. This doesn't happen in 2.1.0. Great work otherwise.
I'm also having the same problem any news @joogps?