lukepistrol / MasonryStack

A Pinterest like layout in SwiftUI (horizontal & vertical).
MIT License
143 stars 4 forks source link

Lazy Loading #1

Open lukepistrol opened 1 year ago

lukepistrol commented 1 year ago

I'd be nice to have the content loading lazily - meaning only the views on screen (or views that are about to be on screen) will be rendered.

Tasks

Let me know if you want to take on this issue by commenting below.

PankajGaikar commented 1 year ago

I implemented a similar solution with help from here - https://stackoverflow.com/questions/66101176/how-could-i-use-a-swiftui-lazyvgrid-to-create-a-staggered-grid

I was on the lookout for such solution for very long time and it looks like the solution was super easy in the end.

lukepistrol commented 1 year ago

@PankajGaikar The problem with this approach is, that it doesn't conform to the Layout protocol which is a nice-to-have when you want to have different layouts in specific contexts or want to allow the user to switch between different layouts.

ltns35 commented 8 months ago

As workaround I've tried using the following code and views are being rendered lazily. But it would be better if library offers this feature.

 MasonryVStack {
    ForEach(array) { item in
        LazyVStack {
            ItemView(item)
        }
    }
}