bhlvoong / LBTATools

Set of tools to drastically improve development speed of UI in iOS applications
MIT License
728 stars 94 forks source link

LBTAListHeaderFooterController initializer #27

Closed sereisoglu closed 4 years ago

sereisoglu commented 4 years ago

Initializer used to write less code for a LBTAListController using a fixed-size and fixed-space cell No need to use UICollectionViewDelegateFlowLayout protocol. And you don't need to use this functions

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    return .init(width: 100, height: 100)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
    return 10
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
    return 20
}
bhlvoong commented 4 years ago

I think itemSize is an acceptable parameter. However, rowSpace and columnSpace is flipped when layoutDirection == .horizontal. I'm also not a big fan of constructors have a long list of optional parameters.

sereisoglu commented 4 years ago

You're right about horizontal, it can be solved with a simple if query. Do you want to restore or fix it? Because only the itemSize parameter has no meaning.

bhlvoong commented 4 years ago

Considering the new introductions of UICollectionViewCompositionalLayout and the implied layout configuration possibilities, I don't want to narrow this API down to UICollectionViewFlowLayout parameters.

Ultimately you should be passing in your own custom layout instance if you want to provide custom configurations such as itemSize and row/line spacing. Extending UICollectionViewFlowLayout to have a convenient initializer would be the better solution in my opinion.