Im using a lazyvgrid with a customImage View that supports lazy loading of a high res image (otherwise thumb is used)
What I'm looking for is some way to initiate my loadFullImage() functionality when the CustomImage view is visible ( onAppear() is not what I need. its called when view is loaded in grid, not when visible )
I've tried variation of this, but they do not work reliably CustomImage(key: key) .background( GeometryReader { proxy in Color.clear .preference(key: ViewVisibleKey.self, value: true) } ) .onPreferenceChange(ViewVisibleKey.self) { isVisible in DispatchQueue.main.async { loadImage(key) } } }
Anyone have any suggestions ? either why the code above doesn't work reliably (its like 10%) , or some other way to accomplish this. Thanks