RORK LABJP
BUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verifyBUILD — Rork Max runs real Macs in the cloud loaded with Xcode and the iOS SDK, writing SwiftUI, compiling, reading the errors and building again. That loop, not the code generation, is what lifts the outputNATIVE — What comes out is pure Swift and SwiftUI, not React Native. Reaching AR, Metal graphics and widgets that React Native cannot touch is the real gap between this and other buildersPLATFORMS — Coverage spans iPhone, iPad, Apple Watch, Apple TV and Vision Pro, plus iMessage. Worth a look if you want to start from a watch app or an extension rather than a phone screenCOMPANION — The Rork Companion app lets you check a generated build on a real iPhone without a paid Apple Developer account, lowering the bar for trying a first project end to endPRICING — Free to start, paid plans from $25 a month, and Rork Max on the $200 Max plan. Worth working out up front how many projects it takes to earn that backDEADLINE — From August 31, 2026, Google Play requires target API level 36 or higher for new apps and updates alike. Ten days out, and the targetSdkVersion of what you generate is yours to verify
Articles/App Dev
App Dev/2026-07-07Intermediate

Laying Out Variable-Height Images in Two Columns: A Masonry Wallpaper Gallery in a Rork Expo App

From why numColumns cannot pack variable-aspect images cleanly, to a dependency-free column-balancing algorithm, to keeping virtualization with FlashList masonry and a pragmatic no-dependency fallback, building a wallpaper gallery with real code.

Rork540Expo176React Native227FlashList5Image Layout

Premium Article

I was rebuilding the grid screen of my own wallpaper app. Tall photos, wide illustrations, and square minimal designs all share one shelf. With a naive grid built by handing numColumns={2} to a FlatList, each row's height was pulled up to the taller image, and a large gap opened below its shorter neighbor. Every swipe brought that gap back into view.

For a wallpaper app, the gallery is the shelf itself. A run of gaps reads as "arranged carelessly." I wanted the images packed together like Pinterest, with no wasted vertical space. That is a masonry layout. Here is the order I actually followed as an indie developer, including where I tripped.

Why numColumns leaves a wallpaper gallery looking sparse

FlatList with numColumns groups your data into rows internally. When you place two per row, that row's height is dictated by the taller of the two images. The shorter one is aligned to the top, and space is left below it.

This is not a bug; it is the nature of a grid. If every image shares the same aspect ratio, nothing goes wrong. The moment portrait, landscape, and square are mixed, as wallpapers are, the gaps appear.

The decision point is clear. If your aspect ratios are uniform, a grid is enough. If they vary and a "densely packed" feel is tied to the quality of the experience, it is worth moving to masonry. Wallpapers, photos, and work portfolios are the classic cases.

The idea behind masonry is to stop aligning by rows and instead stack each column independently. With two columns, you place the next image into whichever column is currently shortest. Repeat that, and the two columns naturally converge in height, minimizing the ragged bottom edge.

Have each image's aspect ratio ahead of time

The first thing masonry needs is each image's aspect ratio. If you design it so the ratio is measured only after the image loads at render time, layout becomes two-phase and stutters during scrolling. You cannot assign an image to a column until its height is known.

There is one clean answer: carry the aspect ratio in the data from the start. I store width and height in each wallpaper's metadata and have the list API return them. Adding a column to a CMS or Supabase table is enough.

Where to store itBenefitCaveat
API/DB metadataKnown before render, fastestRequires recording dimensions on ingest
Encoded in the filename or pathNo DB change neededBreaks if the naming convention slips
Measured once and cachedLeaves existing data untouchedLayout shifts only on the first pass

A minimal type is all you need.

type Wallpaper = {
  id: string;
  uri: string;
  width: number;   // source pixel width
  height: number;  // source pixel height
};

You will not use the raw width and height values themselves; only the ratio matters. Still, keeping the source dimensions is convenient later for thumbnail generation and download-size decisions.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
How numColumns creates empty space with variable-height images, and when masonry becomes worth it
A dependency-free column-balancing algorithm that places each image into the shortest column, with working code
Keeping virtualization with FlashList masonry, plus a realistic fallback when you cannot add a dependency
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

App Dev2026-08-16
My chart broke on day one, not at scale
A line chart that vanished for anyone with only a few days of data. The cause was a zero-height Y axis turning coordinates into NaN. Here is the measured behavior and the small normalization layer that fixed it.
App Dev2026-08-06
Deciding overlay text legibility at ingest time instead of on device — four metrics measured side by side
Moving the question of whether text stays readable over a wallpaper out of the device and into the content pipeline. Four candidate metrics measured across 240 images, including what downscaled judging actually computes.
App Dev2026-07-16
Placing Native Ads in a Masonry Wallpaper Grid: Designing the Lifetime of an Ad Cell
One native ad in a masonry gallery pushed memory from 180 MB to 420 MB over twenty minutes of scrolling. Here is why cell recycling and ad object lifetime never line up, the pool-based implementation that fixed it, and how I picked the insertion interval from measured numbers.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →