I am creating a subview in SwiftUI with few parameters. One of the parameters' type is Namspace.ID. So I have to pass the Namespace.ID type parameter through preview to see the view in Xcode canvas. I don't know how to do it. My codes look like this.
struct BagView: View {
var bagData:BagModel
var animation:Namespace.ID
var body: some View {
VStack{
ZStack{
Color(bagData.image)
.cornerRadius(15)
Image(bagData.image)
.resizable()
.aspectRatio(contentMode: .fit)
.padding(20)
.matchedGeometryEffect(id: bagData.image, in: animation)
}
Text(bagData.title)
.fontWeight(.heavy)
.foregroundColor(.gray)
Text(bagData.price)
.fontWeight(.heavy)
.foregroundColor(.black)
}
}
}
struct BagView_Previews: PreviewProvider {
static var previews: some View {
BagView(bagData: BagModel(image: "bag1", title: "The Bag", price: "$123"))
// I am getting an error here: Missing argument for parameter 'animation' in call
}
}
How can I see the view in Canvas by resolving the error?