onAppear is strangely not getting called for row which are visible later. Im downloading the image in on Appear and then setting it.
List {
ForEach(0..<(viewModel.rows.count), id: \.self) { index in
if let imageModel = viewModel.getImageModel(index: index) {
SomeCustomView(imageModel)
.onAppear {
if imageModel.image == nil {
imageModell.loadAdBanner()
}
}
}
if #available(iOS 15.0, *) {
VStack(spacing: 0) {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 0) {
HeaderView(viewModel:
TitleViewModel(headerTitle: viewModel.rows[index].headerTitle))
Spacer()
TitleView(viewModel: TitleViewModel(row: viewModel.rows[index]))
}
.frame(height: 36)
.padding(.horizontal, 16)
.shimmering(active: viewModel.showShimmer)
.background(viewModel.showShimmer ? .colorDCDCDC : Color.clear)
CategoriesList(l1Category: viewModel.categories[index],
categories: viewModel.categories[index].subcategories,
showShimmer: viewModel.showShimmer)
}
.padding(.bottom, 16)
}
.listRowSeparator(.hidden)
.frame(maxWidth: .infinity) // Make the row take up full width
.listRowInsets(EdgeInsets()) // Remove row insets
.padding(0)
} else {
sameCode without listSepeartor(.hidden)
}