I have the following code in SwiftUI that is working, but I want to show the sales page as a sheet, not as a navigation link.
ForEach(modelData.groupedStories(selectedCategory).shuffled()) {
item in
NavigationLink {
if item.paid == false {
StoryDetails(story: item)
} else {
SalesPage()
}
} label: {
GeneralCard(story: item)
.foregroundColor(.black)
}
}
I don’t know if there is a way to show the sales page as a full cover sheet, that pops from below, with a close button to dismiss, instead of showing in a NavigatioLink
Thanks in advance
2
Answers
I solve it changing where I put the sheet and where the navigation link:
I like to make a State var and toggle it to open my sheet like the following using a
@State var Open: Bool = false
. You will need to wrap the NavigationLink in an if statement.You will likely want to wrap your SalesView with another View so you can pass in the State var as a binding var in order to close the sheet.