Example project showing Compositional Layout and Diffable

Check out my GitHub project for hand-on examples showcasing how to build various layouts using modern APIs.

This post exists mainly to make my Modern Collection Views project more visible. Because I am using this to write blog posts and frequently refer to it. Initially I called it "Compositional Diffable Playground" which may sound cool but it is not very descriptive so now I am calling it Modern Collection Views.

Below is a list of examples that the project currently contains:

  • List layout - list created with Compositional Layout (CL) for iOS 13+
  • Simple grid - grid layout with option to change sizing and see it animate the change
  • Lazy grid example - this grid starts with 12 items and when you scroll at the end it "loads" more
  • Background decoration - this shows how to add background views to section in CL layout. For example you can use this to create layout similar to inset & grouped TableView
  • System list - quick example of creating list layout with the API available from iOS 14
  • Jokes list - this is more an example of Diffable Data Source that is used to display random jokes from an API and also favorited ones that are stored using Core Data. This also shows how to add headers to CL and loading effect. There is also context menu on the items and text-to-speech (because why not?)
  • Badges example - example showcasing adding badges to collection view cells and their positioning
  • Instagram profile screen - this practical example shows how to build screen similar to Instagram profile with Compositional Layout and Diffable. You can read more on my blog

Free free to reach out over at @nemecek_f with issues, questions or anything else.

Uses: Xcode 12 & Swift 5.3


Follow me on Twitter for latest updates and news