-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev angel coronado quintero final delivery #105
base: main-Angel-Coronado-Quintero
Are you sure you want to change the base?
Dev angel coronado quintero final delivery #105
Conversation
DataSource object removed. View Controller now implements data source now, and all logic goes into view model
Implementation of detail screen to MVVM
|
||
import UIKit | ||
|
||
class MovieDetailViewControllerMVVM: UIViewController, MovieDetailViewProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be final
import UIKit | ||
|
||
class MovieDetailViewControllerMVVM: UIViewController, MovieDetailViewProtocol { | ||
var viewModel: MovieDetailViewModelProtocol? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private
viewModel?.fetchAllDetailData() | ||
} | ||
|
||
func bind() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private
self.title = viewModel?.getScreenTitle() | ||
collectionView.collectionViewLayout = CompotitionalLayoutCreator.createLayoutForMovieDetail() | ||
collectionView.setup(dataSource: self) | ||
collectionView.setup(delegate: self) | ||
collectionView.registerNibForCellWith(name: HeaderCollectionViewCell.identifierToDeque) | ||
collectionView.registerNibForCellWith(name: MovieCollectionViewCell.identifierToDeque) | ||
collectionView.reloadData() | ||
let navigationItemReviews = UIBarButtonItem(image: UIImage(named: "reviews"), style: .plain, target: self, action: #selector(showReviewScreen)) | ||
self.navigationItem.rightBarButtonItem = navigationItemReviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make some functions with this
|
||
} | ||
|
||
@objc func showReviewScreen() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private
} | ||
|
||
@objc func showReviewScreen() { | ||
print("show reviews") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deleted
|
||
extension MovieDetailViewControllerMVVM: UICollectionViewDataSource { | ||
func numberOfSections(in collectionView: UICollectionView) -> Int { | ||
return 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid magic numbers
protocol MovieDetailViewModelProtocol { | ||
var movie: MovieProtocol { get set } | ||
var movieDetail: MovieDetailProtocol? { get set } | ||
var similarMovies: MovieList? { get set } | ||
var apiDataManager: MoviesDetailAPIDataManagerProtocol? { get set } | ||
func fetchDetailWith(movie: MovieProtocol) | ||
var didFetchMovieDetail: ((_ movieDetal: MovieDetailProtocol) -> Void )? { get set } | ||
var didFailFetchingMovieDetail: ((_ error: Error) -> Void)? { get set } | ||
func fetchSimiliarMoviesWith(movie: MovieProtocol) | ||
var didFetchSimilarMovies: ((_ movies: MovieList) -> Void)? { get set } | ||
var didFailFetchingSimilarMovies: ((_ error: Error) -> Void)? { get set } | ||
func fetchAllDetailData() | ||
func fetchDetail() | ||
func fetchSimiliar() | ||
var router: MoviesDetailRouterProtocol? { get set } | ||
func showMovieDetailWith(movie: MovieProtocol, from view: UIViewController) | ||
func showMovieReviews(view: UIViewController) | ||
func getScreenTitle() -> String | ||
} | ||
|
||
protocol MovieDetailViewProtocol { | ||
var viewModel: MovieDetailViewModelProtocol? { get set } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this
What does this PR do?
Movie Detail screen with MVVM architecture.
Where should the reviewer start?
Movie Detail
Code review checklist Code Review Rubric
DRY Principle (Don’t repeat yourself)
Yagni Principle (You Aren't Gonna Need It)
KISS Principle (Keep It Simple, St...d)
Remove unused code
Hard-coded values
Language style guide & coding conventions
Wizeline Style Guide
RayWenderlich Style Guide
Architecture / Design Pattern
Architecture Implementation
SOLID
Single Responsibility Principle
Open Closed Principle
Liskov substitutability principle
Interface segregation
Dependency Inversion principle
Testing
Force unwrapping !
Mutable vs immutable property (Right use of
let
andvar
)Retain cycles (Capture list)
Code Documentation