This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum MovieType: String { | |
case Poster = "Poster" | |
case Cover = "Cover" | |
case Side = "Side" | |
static var allValues = [Cover, Poster, Side] | |
} | |
struct MovieCellItem { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol CellItem { | |
func reuseIdentifier() -> String | |
func cellNib() -> UINib? | |
func configureCell(cell: UICollectionViewCell) | |
func cellSize(maxSize: CGSize) -> CGSize | |
func register(collectionView: UICollectionView) | |
} | |
extension CellItem { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ViewModelDelegate: class { | |
func viewModelDidStartLoad() | |
func viewModelDidLoad() | |
func viewModelDidFail() | |
} | |
class ViewModel: NSObject { | |
// MARK: - Properties | |
private weak var delegate: ViewModelDelegate? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func registerCells() { | |
guard let vm = self.viewModel else { | |
return | |
} | |
for item in vm.items { | |
item.register(self.collectionView) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ViewController: ViewModelDelegate { | |
func viewModelDidStartLoad() { | |
print("Started !") | |
} | |
func viewModelDidLoad() { | |
self.registerCells() | |
self.collectionView.reloadData() | |
} | |