I can help you with adding a product to the cart from the sheet. The CartManager has the function to add a product to the cart.
To add a product in your sheet, add a property for the cart manager to ProductDetailSheet. Because CartManager is a class, you should use the @ObservedObject property wrapper for the cart manager.
@ObservedObject var cart: CartManager
You have not shown the code for the view that opens the sheet. But in that sheet you must add a property with the @StateObject property wrapper for the cart manager.
@StateObject var cart: CartManager
Pass the cart to the sheet.
When someone taps the Add button, call the addToCart function to add the product to the cart.
Button("Add") {
cart.addToCart(product: product)
isSheetPresented = nil
}
I am not sure if this is enough to get the product adding working, but it should give you a start.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: