Implement Collection View Compositional Layout
CompositionalLayoutableSection
The way I follow to easily implement Collection View Compositional Layout without doing a lot of switch cases
Using this can lead to better organization and abstraction of your code, as well as making it easier to reuse and maintain.
I converted it to a package That you can easly use by adding it to your project by Package Manager
https://github.com/ahmed-yamany/CompositionalLayoutableSection.git