I made a struct to represent a section in the UI.
@Observable class Model {
struct Section: Identifiable {
var id: String {
return title
}
let title: String
let products: [String]
let productViewStyle: any ProductViewStyle
}
let sections: [Section]
init(sections: [Section]) {
self.sections = sections
}
}
Each section has it's own productViewStyle which is a SwiftUI protocol with associatedtype. I can create the model:
let test = InAppPurchase.Products.Model(sections: [InAppPurchase.Products.Model.Section(title: "test", products: ["testProdutID"], productViewStyle: .large)])
When I want to use it on the UI I got an error:
ProductView(id: test.sections.first!.products.first!)
.productViewStyle(test.sections.first!.productViewStyle)
Type 'any ProductViewStyle' cannot conform to 'ProductViewStyle'
How can I solve this issue?