Displaying Photos by Moment with Section Headers

One feature I knew I wanted Snapthread to have from very early on was the ability to display a user’s photo library in a similar way to the native Photos.app: scrolled to the bottom, sorted by Moment, with selectable sections. What I ended up implementing is actually closer to the Photos app within the Xcode device simulator: it can’t “zoom” in and out of Moment clusters, but it can display assets organized in sections by location and date.

I created a sample project to demonstrate how I did that and put it on GitHub. This is the first time I’ve ever shared code on GitHub, and I know it’s not particularly good, but if you run the project on your device you should see just what I described: your most recent photos and videos at the bottom of the collection view, sorted by Moment. The project loads the user’s first 25 Moments immediately, and then performs a background fetch for the rest, refreshing the collection view only if the user scrolls to the top of the currently loaded content.

There might be much better ways to accomplish this. I welcome any feedback!

Here’s the project link again, for those interested: SwiftyPhotoMoments on GitHub.

One thought on “Displaying Photos by Moment with Section Headers

Comments are closed.