GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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 RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates.

Learn more here

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.