airbnb / airbnb/MagazineLayout

Why MagazineLayoutCollectionViewLayoutAttributes is `final`?

Open
#67 3 comments 0 reactions 1 assignee Claimed by @bryankeller View on GitHub
enhancement
Dominant language
Swift
Stars
3.4k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

**The problem**
I use `UICollectionView` with custom layout in my app. I wanted to migrate to `MagazineLayout`. But I use custom `UICollectionViewLayoutAttributes`, so I need to somehow extend `MagazineLayoutCollectionViewLayoutAttributes` to use with my cells.
But since `MagazineLayoutCollectionViewLayoutAttributes` is final - I can't just subclass it.

**The solution I'd like**
Make it non-final

**Alternatives I've considered**
a) Make `MagazineLayout` non-final, and let subclasses provide type of `UICollectionViewLayoutAttributes` which conforms to protocol:

```
protocol IMagazineLayoutCollectionViewLayoutAttributes {
public var shouldVerticallySelfSize: Bool { get set}
}
```

Make MagazineLayoutCollectionViewLayoutAttributes conform this protocol :
```
extension MagazineLayoutCollectionViewLayoutAttributes: IMagazineLayoutCollectionViewLayoutAttributes {}
```
b) Use objc runtime to extend `MagazineLayoutCollectionViewLayoutAttributes`
c) Add property into `MagazineLayoutCollectionViewLayoutAttributes` (some key-value collection), to hold additional parameters

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.