-
Notifications
You must be signed in to change notification settings - Fork 0
CR file Change #1
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
base: feature/code-review
Are you sure you want to change the base?
Conversation
zeeshansuleman
left a comment
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.
Couple of comments added to improve the code.
|
|
||
| func callbacks() { | ||
| view.backgroundColor = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1) | ||
| customView.didTapButton = { |
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.
Closure must be used with capture list to avoid memory leaks.
| let payment: Payment? | ||
|
|
||
| func callbacks() { | ||
| view.backgroundColor = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1) |
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.
create a color extension and define proper name for the colors to increase code readability, Also it will be useful to reuse the color at different places.
|
|
||
| class paymentViewController: UIViewController { | ||
| var delegate: PaymentViewControllerDelegate | ||
| let customView = PaymentView() |
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.
should be "lazy" var to load in memory when used.
| // | ||
|
|
||
| class paymentViewController: UIViewController { | ||
| var delegate: PaymentViewControllerDelegate |
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.
Use "weak" for the delegates to avoid retain cycle.
| } | ||
|
|
||
| func viewDidLoad() { | ||
| navigationController?.setNavigationBarHidden(false, animated: false) |
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.
super call for viewdidload is missing.
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.
Also please move all the code from view did load method to a seperate method e.g setupInterface()
| setupCallbacks() | ||
| } | ||
|
|
||
| internal let ViewModel: PaymentViewModel |
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.
first character of variable name must be lowercase.
|
|
||
| func fetchPayment() { | ||
| customView.statusText = "Fetching data" | ||
| ApiClient.sharedInstance().fetchPayment { payment in |
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.
use unowned capture list in closure.
| customView.statusText = "Fetching data" | ||
| ApiClient.sharedInstance().fetchPayment { payment in | ||
| self.CustomView.isEuro = payment.currency == "EUR" ? true : false | ||
| if payment!.amount != 0 { |
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.
avoid force unwrapping and use if let or guard statement to avoid crash if the value is nil
| ApiClient.sharedInstance().fetchPayment { payment in | ||
| self.CustomView.isEuro = payment.currency == "EUR" ? true : false | ||
| if payment!.amount != 0 { | ||
| self.CustomView.label.text = "\(payment!.amount)" |
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.
remove force unwrapping here as well.
No description provided.