Skip to content

ericleiyang/CompositionalLayoutSpreadsheet

Repository files navigation

CompositionalLayoutSpreadsheet

License Platform Swift Package Manager compatible

Example

To run the example project, clone the repo, and run CompositionalLayoutSpreadsheetExample.xcodeproj from the example directory.

Requirements

iOS 13.0 + Swift 5.0 +

SPM Installation

CompositionalLayoutSpreadsheet is available through Swift Package Manager. To install it, simply add the following line to your Podfile:

dependencies: [
    .package(url: "https://github.com/ericleiyang/CompositionalLayoutSpreadsheet.git", .upToNextMajor(from: "1.0.0"))
]

Demo

Output sample

Features

  • Spreadsheet like collection view
  • Compositional collection view layout
  • Sticky column at the left
  • iPhone screen sizes supported
  • iPad screen sizes supported
  • Device rotation supported
  • Custom sticky size width supported
  • Custom value cell size supported
  • Custom sticky cell font/color supported
  • Custom value cell supported
  • Sticky row as the header
  • Multiple sticky columns at the left
  • Multiple sticky rows as the header
  • Various row sizes supported
  • Various column sizes supported

Quick start

A short introduction on how to get started:

  • The sticky column is represented as ReusableSupplementaryView.
  • The values are represented as one NSCollectionLayoutSection with multiple NSCollectionLayoutGroup.
  • Default cell is the ValueCell with one label displayed. It can be replaced by custom UICollectionViewCell when calling configureHierarchy of the CompositionalLayoutSpreadsheet.

A short example:

//Init
let provider = CompositionalLayoutSpreadsheet()

// Use default ValueCell
provider.configureHierarchy(
    stikyColumnDatas: stikyColumnDatas,
    rowDatas: rowDatas,
    parentView: view
)

To use the custom cell:

//Init
let provider = CompositionalLayoutSpreadsheet()

// Use default ValueCell
provider.configureHierarchy(
    stikyColumnDatas: stikyColumnDatas,
    rowDatas: rowDatas,
    cell: YOUR CELL,
    cellReuseIdentifier: The reuse identifier of YOUR CELL
)

Reload after data updated:

provider.update(
    stikyColumnDatas: UPDATED COLUMN DATA,
    rowDatas: UPDATED VALUES
)

Enjoy ;)

Questions

Please refer to the demo application or contact me directly.

Author

Eric Yang

License

CompositionalLayoutSpreadsheet is available under the MIT license. See the LICENSE file for more info.