Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Exposure submission coordinator #910

Merged
merged 15 commits into from
Jul 17, 2020

Conversation

johannesrohwer
Copy link
Member

This PR refactors the exposure submission flow to use a coordinator instead of individual segues. To test the changes, I recommend to mock the ExposureSubmissionService that is provided to the coordinator in the HomeInteractor which allows testing all screens even with limited access to the backend.

Checklist

  • This PR does not change text that hasn't been signed off with the RKI. Have a look at the pinned issue 440
  • Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests.
  • Set a speaking title. Format: {task_name} (closes #{issue_number}). For example: Use logger (closes # 41)
  • Make sure that your PR is not introducing unnecessary reformatting (e.g., introduced by on-save hooks in your IDE)

Description

@johannesrohwer johannesrohwer added the chore Refactoring label Jul 15, 2020
Copy link
Member

@melloskitten melloskitten left a comment

Choose a reason for hiding this comment

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

Hi! Thanks for this major refactor of the navigation flow in the exposure submission part 👍 . Please take a look at some of my comments.

// MARK: - Navigation.

/// Starts the coordinator and displays the initial root view controller.
func start(with result: TestResult?)
Copy link
Member

Choose a reason for hiding this comment

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

where's the "start with intro screen" part? in case it is handled by the same method, make sure to mention it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, this is misleading! I will add a comment to clarify this behavior

}

/// Concrete implementation of the ExposureSubmissionCoordinator protocol.
class ESCoordinator: ExposureSubmissionCoordinator {
Copy link
Member

Choose a reason for hiding this comment

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

not a fan of the naming here, to be honest! Is there any better way you could name the protocol and the concrete implementation class?

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe something like:

  • protocol: ExposureSubmissionCoordinating
  • implementation: ExposureSubmissionCoordinator

Copy link
Member

Choose a reason for hiding this comment

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

If you want to set ExposureSubmissionCoordinatorViewController as a Marker protocol only for view controller, you can use this syntax:

  protocol ExposureSubmissionCoordinatorViewController: UIViewController {
	var coordinator: ExposureSubmissionCoordinator? { get set }
}

This constraint makes sure, it can only be used by UIViewController.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the proposal, I will remember your tip! However, I was able to completely get rid of the protocol by injecting the coordinator via the initializer 🎉 I guess that is simpler and cleaner than my initial approach

// MARK: - Helpers.

private func push(_ vc: UIViewController) {
self.navigationController?.pushViewController(vc, animated: true)
Copy link
Member

Choose a reason for hiding this comment

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

which of our views are pushed and which are presented? why is the differentiation needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

the default behavior is push. however, the QR Scanner comes with its own navigation controller that needs to be presented. therefore i added the two separate methods.

Comment on lines 204 to 205
exposureSubmissionService: self.exposureSubmissionService,
testResult: result
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for passing in the exposure submission service like this? I believe since we now have the coordinator, this is not necessary. please double check this.

Copy link
Member Author

Choose a reason for hiding this comment

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

the coordinator injects the service into the view controller. Am I missing something here?


// MARK: - Attributes.
Copy link
Member

Choose a reason for hiding this comment

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

please leave break inbetween MARK and code. you did it for the rest of the change as well

weak var scannerViewController: ExposureSubmissionQRScannerViewController? {
viewControllers.first as? ExposureSubmissionQRScannerViewController
}

// MARK: - Initializers.
Copy link
Member

Choose a reason for hiding this comment

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

same as above

withIdentifier: Segue.labResultsSegue,
sender: self
)
// A TAN always indicates a positive test result.
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the comment 👍👌

func start(with result: TestResult?)
func dismiss()

func showOverviewScreen()
Copy link
Member

Choose a reason for hiding this comment

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

In MockExposureSubmissionCoordinator you had empty lines between each of those methods. please adjust in a unified way.

Copy link
Member

@haosap haosap left a comment

Choose a reason for hiding this comment

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

Nice refactoring👍 , please check my comments.

}

/// Concrete implementation of the ExposureSubmissionCoordinator protocol.
class ESCoordinator: ExposureSubmissionCoordinator {
Copy link
Member

Choose a reason for hiding this comment

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

If you want to set ExposureSubmissionCoordinatorViewController as a Marker protocol only for view controller, you can use this syntax:

  protocol ExposureSubmissionCoordinatorViewController: UIViewController {
	var coordinator: ExposureSubmissionCoordinator? { get set }
}

This constraint makes sure, it can only be used by UIViewController.

* develop:
  Improved readability.
  Changes in accordance with PR feedback.
  Adjust DynamicTableViewTextViewCell tint color
  Add more unit tests
  Add unit tests for DynamicTableViewTextViewCell
  Impressum + DynamicTableViewTextViewCell changes
  DynamicTableViewTextViewCell background color fix
  DynamicTableViewTextViewCell fixes
  Add interactivity to App Settings Imprint Screen
  Display underline in ENATanInput when character is invalid.
@johannesrohwer johannesrohwer marked this pull request as ready for review July 17, 2020 08:21
@johannesrohwer johannesrohwer requested a review from a team July 17, 2020 08:21
weak var delegate: ExposureSubmissionCoordinatorDelegate?
weak var parentNavigationController: UINavigationController?

/// - Note: We keep a weak reference here to avoid a reference cycle.
Copy link
Member

Choose a reason for hiding this comment

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

just a teeny tiny comment: Up in line 62 you wrote NOTE capitalized. It's great that you have added so many comments though, love it! 😊

Copy link
Member

@melloskitten melloskitten left a comment

Choose a reason for hiding this comment

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

Hi! I have just found 2 minor things to look at. Would be cool if you ad changed them. Nonetheless, I will approve. Cheers! 👌

var coordinator: ExposureSubmissionCoordinator?
private(set) weak var coordinator: ExposureSubmissionCoordinating?
private(set) weak var exposureSubmissionService: ExposureSubmissionService?

Copy link
Member

Choose a reason for hiding this comment

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

remove this line here

@johannesrohwer johannesrohwer merged commit 3825e89 into develop Jul 17, 2020
@johannesrohwer johannesrohwer deleted the chore/exposure-submission-coordinator branch July 17, 2020 09:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
chore Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants