I struggled with this as well. However, I found a different way that achieves the same objective while working on AppleTV. That is to use a TabView which when styled works like a page controller. This allows you to swipe left/right on a an array of images. Given it works page by page and loading is as-needed so it works like a lazystack. Here is a full example for you (note I styled it so that it doesn't show page markers, but you can simply use .page if you want them).
struct SlideshowViewer: View {
@State private var gallery = GalleryPublisher.shared
var body: some View {
TabView {
ForEach(gallery.slideshow, id:\.self) { slideshow in
ImageView(slideshow: slideshow)
.focusable(true)
.frame(width:UIScreen.main.bounds.width,height: UIScreen.main.bounds.height)
.edgesIgnoringSafeArea(.all)
}
}
.tabViewStyle(.page(indexDisplayMode: .never))
}
}
struct ImageView: View {
var slideshow:Slideshow
@State private var galleryImage:UIImage?
var body: some View {
if let image = galleryImage {
Image(uiImage: image)
.resizable()
.aspectRatio(contentMode:.fill)
} else {
ZStack {
Rectangle()
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: .blue))
}
.foregroundColor(.white)
.onAppear {
NetworkManager.shared.downloadImage(urlStr: slideshow.link) { image in
galleryImage = image
}
}
}
}
}