-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ronan Nunes
committed
Oct 8, 2019
1 parent
f31e3eb
commit 8e25ec6
Showing
5 changed files
with
112 additions
and
17 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
iOS/Sources/ListFood/ListFoodCollectionViewController.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// ListFoodCollectionViewController.swift | ||
// iOS | ||
// | ||
// Created by Ronan Nunes on 08/10/19. | ||
// Copyright © 2019 Ronan Nunes. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
private let reuseIdentifier = "Cell" | ||
|
||
class ListFoodCollectionViewController: UICollectionViewController { | ||
|
||
private var cellIdentifier: String = String(describing: ListFoodCollectionViewController.self) + "Cell" | ||
private let sectionInsets = UIEdgeInsets(top: 50.0, left: 20.0, bottom: 50.0, right: 20.0) | ||
private var viewModel = ListFoodViewModel.empty | ||
private var groupedFoodViewModels: [GroupedFoodViewModel] { return viewModel.groupedFoodViewModels } | ||
@IBOutlet var dependency: ListFoodViewControllerDependency! { | ||
didSet { | ||
dependency.presenter.bindable = self | ||
dependency.interactor.list() | ||
} | ||
} | ||
|
||
override func numberOfSections(in collectionView: UICollectionView) -> Int { | ||
return groupedFoodViewModels.count | ||
} | ||
|
||
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
let group = groupedFoodViewModels[section] | ||
return group.foods.count | ||
} | ||
|
||
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) | ||
cell.backgroundColor = .orange | ||
return cell | ||
} | ||
} | ||
|
||
extension ListFoodCollectionViewController: ListFoodTableViewControllerBind { | ||
func bind(viewModel: ListFoodViewModel) { | ||
self.viewModel = viewModel | ||
title = viewModel.title | ||
collectionView.reloadData() | ||
} | ||
|
||
func bind(errorViewModel: ListFoodErrorViewModel) { | ||
} | ||
} |
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
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
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
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