I have the following data which is my identifiable. What I am trying to do is that I want to add a type
of view
as well so later I can give a Button
that will link to those views. I don't know how to accomplish this. It says it doesn't accept view type.
My aim is to create cards and each card will hold Datum
values. I want to set a Button
to each of them that will take the user to that specific view. Since I do a ForEach
, I want to be able to add each Datum
's view. I did the following but swift didn't accept it and threw error.
Here is the code:
struct Datum:Identifiable {
var id = UUID()
var subtitle:String
var name:String
var footnote: String
var description:String
var image:String
var categoryTag:String
var comingSoon:Bool
//var modelName: **View**
}
public var categoriesList = ["DL", "TSA", "NLP"]
var ModelsData:[Datum] = [
Datum(subtitle: "Deep Learning",
name: "Mask Detection",
footnote: "An image classificaton model.",
description: "This model classifies whether a person has a mask or not. You simply take your camera and then take your face. Then, it will go and scan it. After that, you will see that at the bottom it shows green (means you have a mask) or red (which means you dont have a mask.)",
image: "MaskDetectionImage",
categoryTag: "DL",
comingSoon: false,
//modelName: MaskDetectionView()), //I want to add a view
Datum(subtitle: "Deep Leaning",
name: "Video games",
footnote: "An image classificaton app",
description: "This model classifies whether a person has a mask or not. You simply take your camera and then take your face. Then, it will go and scan it. After that, you will see that at the bottom it shows green (means you have a mask) or red (which means you dont have a mask.)",
image: "latest_1",
categoryTag: "DL",
comingSoon: false,
//modelName: ContentView())] //Another different view
Here is image:
This will give you some idea of how to start structuring it and how to keep the Datum model independent of SwiftUI (or however else you want to present it, save it etc).