Return different views for fullScreenCover method

Hi guys.
I'm new here.
Unfortunately, I couldn't find an answer related to present different views as modal in fullScreenCover based on the view type.
And I hope we will find the right way quickly =).

So the goal: I would like to show different views using the single fullScreenCover.

What I have:
  1. I defined enum with possible view types.

Code Block language
enum FullScreenType: Int, Identifiable {
var id: Int { rawValue }
case none
case seasonDetails
case topTimes
}


2. Defined method that returns a required view

Code Block language
func makeFullScreenContent(_ fullScreenType: FullScreenType) -> some View {
return Group {
switch fullScreenType {
case .seasonDetails:
SeasonDetailsView(selectedSeason: self.$season, showModal: $showModal)
case .topTimes:
TimesView(eventId: $eventId, showModal: $showModal)
case .none:
EmptyView()
}
}
}


3. My ContentView looks as:

Code Block language
struct ContentView: View {
// some code
// ...
@State private var showModal = false
@State private var fullScreenType: FullScreenType? = Optional.none
var body: some View {
VStack {
// some stuff
// ...
if card.flipped {
self.fullScreenType = .topTimes
self.showModal.toggle()
} else {
self.fullScreenType = .seasonDetails
self.showModal.toggle()
}
}
}
.fullScreenCover(item: $fullScreenType, content: { fullScreenType in
makeFullScreenContent(fullScreenType)
})
}
}

Here I would like to keep Binding property showModal to close my custom views.
But the main problem is -> my custom view isn't open.
I debugged code and I made sure the corresponding views return.
So what is the problem?

oh, Jesus.

In my ContentView I have OnboardingView and I present it as sheet.... i.e. I have two view modifiers:

Code Block language
struct ContentView: View {
// some code
// ...
@State private var showModal = false
@State private var fullScreenType: FullScreenType? = Optional.none
var body: some View {
VStack {
// some stuff
// ...
if card.flipped {
self.fullScreenType = .topTimes
self.showModal.toggle()
} else {
self.fullScreenType = .seasonDetails
self.showModal.toggle()
}
}
}
.fullScreenCover(item: $fullScreenType, content: { fullScreenType in
makeFullScreenContent(fullScreenType)
})
.sheet(isPresented: $showOnboarding) {
OnboardingView()
}
}
}

If I comment sheet modifier I will enter into custom full-screen views... So it seems, we can't use fullScreenCover and sheet. Am I right?
Unfortunately, you seem to be right. This is quite an annoying bug in SwiftUI.
Return different views for fullScreenCover method
 
 
Q