UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to add LazyVGrid row seperators?

Forums > SwiftUI

Newbie Swift/SwiftUI developer here.

I'm adding row seperators to a LazyVStack, and avoiding the last row by capturing the last item and comparing each item at render time.

LazyVStack( alignment:.leading, spacing: 6 ) {
    let lastItem = document.data.research.competition.last
    ForEach( document.data.research.competition ) { item in
        DownloadPreviewRow(title: item.title, tagline: item.slogan, price: item.price )
        if item != lastItem { Divider() }
    }
}

But I can't figure out how to apply this to a LazyVGrid when using Adaptive GridItems for the columns, does anyone have any suggestions? Basically, I don't know how many cells are in a row, and even if I did, the lack of an index makes it harder.

I have tried searching online, but it appears that my GooglFu might be too weak.

LazyVGrid( columns: [GridItem( .adaptive(minimum: 300, maximum: 450))] ) {
    ForEach( document.data.research.competition ) { item in
       AppStorePreviewCell(title: item.title, tagline: item.slogan, price: item.price )
    }
}

1      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.