Following an online tutorial for RevenueCat- Which calls information from an Array. This presents scrollable Pictures as clickable buttons. The problem that I am having is creating a Navigationlink to the different pictures relative to the information from the array/Model information. Any Pointers would be most appreciated
struct Meditation: Identifiable {
var id = UUID()
var title:String = ""
var desc:String = ""
var imageName = ""
var productId:String?
static func getSampleMeditations() -\> \[Meditation\] {
var array = [Meditation]()
var m1 = Meditation()
m1.title = "GP Calculator"
m1.desc = "Simple GP Calculator"
m1.imageName = "ambition"
m1.productId = "ambition"
array.append(m1)
-----------
struct ContentView: View {
@EnvironmentObject var userViewModel: UserViewModel
@State var isPaywallPresented = false
var body: some View {
TabView {
NavigationView {
ScrollView (showsIndicators: false) {
VStack (alignment: .leading) {
ForEach(Meditation.getSampleMeditations()) { meditation in
Button {
if userViewModel.isSubscriptionActive {
NavigationLink(destination: Meditation(array: meditation) )
}
else {
isPaywallPresented = true }
} label: {
Card(meditation: meditation)
.padding(.bottom, 20)
}
}
// TODO: Show meditation
// NavigationLink(destination: GP_Calculator() )
// Meditation.getSampleMeditations()
// NavigationLink(destination: Meditation(array: meditation) )
// Meditation(meditation: title)
// ContentView()