Image Carousel in SwiftUI

I'm trying to implement image carousel with dots in SwiftUI following this article SwiftUI: How to create a Horizontal Paging ScrollView? | by Prafulla Singh | Medium

I'm getting images from JSON, nested array.

My model:

struct MarketPlaceData: Decodable, Hashable, Identifiable {
      let id = UUID()
      let name: String
      let status: String
      let regular_price: String
      let price_html: String
      let images: [ProductImage]

struct ProductImage: Decodable, Hashable, Identifiable {
      let id = UUID()
      let src: String

Image carousel implementation:

struct FullCarousel: View {

var body: some View {
    ScrollView {
        LazyHStack {

struct ImageCarousel: View {
@ObservedObject var viewModel = ProductViewModel()

var body: some View {
    TabView {
        ForEach(viewModel.products) { item in
            ForEach(item.images) { image in
                ZStack {
                    WebImage(url: URL(string: image.src))
                        .frame(width: 100, height: 100, alignment: .center)
                }.padding(.all, 10)
}.frame(width: UIScreen.main.bounds.width, height: 200)

As a result I can't see preview. I tried just image parsing and image carousel 
with simple image array in separate views and both work properly, 
but I can't combine them. 

I searched for many implementations of Image Slider and stopped on this. 
Can't understand why this tutorial don't work for my task.
Terms of Service

Privacy Policy

Cookie Policy