-
Start with Classes -> Modules -> Cart -> Section
-
In this folder you can see all section type that we have in cart. ( PS. LACartSection is legacy class)
-
I use
IGListBindingSectionController
for SectionController with this way it will automatically bind viewModel and cell for us. -
in sectionController class, we have to implement some dataSource methods
- First we need to return all viewModel for section
- Each viewModel will map to cell so relationship for viewModel and cell will be 1 to 1. So its mean a viewModel will have a cell to show.
- I use category to separate logic for build viewModels , for the final result we will return array of viewModel to IGListKit and all of this viewModel will be mapped to cell.
- You can check
category
in folderClasses -> Modules -> Cart -> Categories
- If you start reading code at sectionController you will see category of viewModel try to ask a list of viewModel from child viewModel . I use this way because I try to separate viewModel building logic. its kind of duplicate method but with this way the logic will be in specific place.
-
viewModel will be separated by type of business domain like
LACartSellerViewModel
,LACartLocationViewModel
etc. please checkClasses -> Modules -> Cart -> ViewModels
folder- Each viewModel will hold branch of
componentViewModel
and we will always use component viewModel to map to cell - I designed these viewModel like hierarchy of viewModel. And we have only one way to talk with other module by talk to parent viewModel first. So its mean every action that made from child viewModel will be sent to parent viewModel first.
- In component header you can see two parts of block call back, first for binding cell and second for talk with parent viewModel.
- Each viewModel will hold branch of
For sample project please check Cart Repo. In this repo I try to simulate our cart architecture.