Updating our product views
Now we'll move on to updating our prototype and making it work with iCloud, as well as building out the interactivity. Before we jump into updating all of our files, we need to set up our ObservableObject
. Open ShoePOSApp
and add the following variables above the body
variable:
@StateObject private var cart = ShoppingCart()
Next, update ContentView()
with the following:
ContentView() .environmentObject(model) .environmentObject(cart) .onAppear { model.fetchAllProducts() }
We now have our environmentObject
set up and the model fetching the products and brands when the app launches.
Next, we will update all of our views for the products, and then we will turn our attention to the cart views. Since SizeCartItemView
is something we use in both views, we are going to start with this first:
- Open...