m1rr0r-t34m / interactive-grid

Demo project showing a technique for building a reorderable `UICollectionView` using compositional layout and other stock UIKit APIs.

Home Page:https://briancoyner.github.io/articles/2021-10-12-reorderable-collection-view/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building An Interactive Grid View

Goals

This demo shows a few techniques on how to build a re-ordable grid view based on stock UICollectionView API.

Here are the main UIKit APIs used by this demo:

  • UICollectionViews compositional layout API.
  • UICollectionViewDiffableDataSource and its reordering support.
  • UIContextMenuConfiguration for presenting optional menus from each displayed cell.

The view is driven by a two-column layout that supports two cell sizes:

  • Compact (half width)
  • Regular (full width)

Other goals

  • The layout must dynamically adjust while the user drags cells arounds.
  • The user must be able to long-press on cell to present a standard iOS context menu.

Additional details can be found in this blog post.

About

Demo project showing a technique for building a reorderable `UICollectionView` using compositional layout and other stock UIKit APIs.

https://briancoyner.github.io/articles/2021-10-12-reorderable-collection-view/

License:MIT License


Languages

Language:Swift 100.0%