lxcid/LXReorderableCollectionViewFlowLayout

Is it necessary to be a subclass?

Closed this issue · 2 comments

What makes it necessary for this logic to be a subclass of UICollectionViewFlowLayout? Can't we apply the Decorator design pattern to a UICollectionView?

I ask because I have my own UICollectionViewFlowLayout subclasses, and this forces me to make changes to the LXReorderableCollectionViewFlowLayout code.

Could you subclass from LXReorderableViewFlowLayout instead of UICollectionViewFlowLayout?

I haven't though of making it so modular in the sense that it doesn't require subclassing. But we do needs to override these methods to make it work. These overridden methods are just for hiding the selected index path. Other behavior are done by using gesture recognizer. So its pretty lightweight and you should not face too much of a problem overriding from LXReorderableViewFlowLayout instead.

Could you subclass from LXReorderableViewFlowLayout instead of UICollectionViewFlowLayout?

Yes. The thing is that not all layouts that use my UICollectionViewFlowLayout subclass need to be "reorderable".

Looks like overriding those methods is the way Apple recommends dealing with gestures. Pity. If only layouts had a delegate method for layoutAttributesForItemAtIndexPath.