Skip to content
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

Add cr.swift file #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Add cr.swift file #1

wants to merge 1 commit into from

Conversation

adamgolczak
Copy link
Owner

No description provided.

@adamgolczak adamgolczak self-assigned this Mar 1, 2022
//

class paymentViewController: UIViewController {
var delegate: PaymentViewControllerDelegate
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add 'weak' keyword to avoid ARC isssues - strong reference cycle

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are sure that this delegate would be never a nil, you can consider using 'unowned' keyword

Comment on lines +7 to +8
let customView = PaymentView()
let payment: Payment?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider encapsulating those variables, if they won't be used outside the file
public -> private

// Netguru iOS code review task
//

class paymentViewController: UIViewController {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add a keyword 'final' to the view controllers, to avoid inheritance by a mistake.
I consider it a good practice :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a 'PaymentViewControllerProtocol' to satisfy dependency inversion principle which says: "let’s make the high level and the low level structures depend on abstractions".

//
// Netguru iOS code review task
//

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot about importing UIKit :)

@@ -0,0 +1,41 @@
//
// Netguru iOS code review task
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave information about the author of the file :)

customView.statusText = "Fetching data"
ApiClient.sharedInstance().fetchPayment { payment in
self.CustomView.isEuro = payment.currency == "EUR" ? true : false
if payment!.amount != 0 {
Copy link
Owner Author

@adamgolczak adamgolczak Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard would be a far better solution in my opinion
force unwrap is a bad practice

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, I would consider a isZero, but it's not a necessity :)

ApiClient.sharedInstance().fetchPayment { payment in
self.CustomView.isEuro = payment.currency == "EUR" ? true : false
if payment!.amount != 0 {
self.CustomView.label.text = "\(payment!.amount)"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you have misspelled customView name :)

Comment on lines +22 to +23
customView.centerXAnchor.constraint(equalTo: view.centerXAnchor)
customView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no isActive = true for those constraints

setupCallbacks()
}

internal let ViewModel: PaymentViewModel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable names should be in camel case

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would also bring it to the top, along the other variables

view.backgroundColor = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1)
customView.didTapButton = {
if let payment = self.payment {
self.delegate.didFinishFlow(amount: payment.amount
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot about a comma :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant