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

Show QR Code scanner as push view, not modal (#782) #789

Closed
wants to merge 23 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 29, 2018

@vikmeup , referencing #782 issue. I have started to alter the code. I have moved logic for creating and navigating QR Code scanner from SendViewController to SendCoordinator, since it seems to me, it is coordinators responsibility, and then having a controller reference, I update it using a new dedicated function.

I will proceed to implement this change in all the other places. If you have any comments, feel free.

Edit: I could not test a browser, because it is not working right now.

@BlackDuckCoPilot
Copy link

BlackDuckCoPilot commented Jun 29, 2018

Black Duck Security Report

Merging #789 into master will not change security risk.

Click here to see full report

@OlegGordiichuk
Copy link
Contributor

@BloodyPixy could you pls fix lint warnings.

@ghost
Copy link
Author

ghost commented Jun 29, 2018

@OlegGordiichuk , I am not done yet.

@ghost
Copy link
Author

ghost commented Jun 29, 2018

@OlegGordiichuk , @vikmeup , I have more or less finalized this. In some cases, this is impossible to handle via coordinator, as there in no any.

@vikmeup
Copy link
Contributor

vikmeup commented Jun 29, 2018

@BloodyPixy You gotta build a generic solution to push coordinator, I can work on this later, but there is an example on the internet how it's done, it removes reference to the navigation.

@vikmeup
Copy link
Contributor

vikmeup commented Jun 29, 2018

@BloodyPixy take a look at this: https://irace.me/navigation-coordinators, we only need logic for pushCoordinator() make it as protocol?

* master:
  Remove explore collectibles
  Add gesture handle for words
  Move navigation bar on pushing backup
  Version Bump
  Version Bump
  Version Bump
  Version Bump
  Change copy
  Make private key image view fixed size
  Disable import from file
  Improve backup phrase expirience
  Revert to use previos old provider version
  Add CFBundleAllowMixedLocalizations
  Rename to Backup Phrase
  Add skip functionality
@ghost
Copy link
Author

ghost commented Jul 1, 2018

@vikmeup , check new commits. I believe that's much better and can be applied to all coordinators.

@vikmeup
Copy link
Contributor

vikmeup commented Jul 1, 2018

@BloodyPixy Nice work! I will take another look tomorrow!

}
}

protocol RootViewControllerProvider: class {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move into separate file?

Copy link
Author

Choose a reason for hiding this comment

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

Even in two

Copy link
Contributor

@vikmeup vikmeup left a comment

Choose a reason for hiding this comment

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

Are you sure that's correct way to solve it?

I think coordinator need to conform instead, so you can push coordinator from the coordinator! It should not be navigation controller

extension NewTokenViewController: ScanQRCodeCoordinatorDelegate {
func didCancel(in coordinator: ScanQRCodeCoordinator) {
navigationController?.setNavigationBarHidden(false, animated: false)
(navigationController as? NavigationController)?.popCoordinator(coordinator)
Copy link
Contributor

Choose a reason for hiding this comment

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

navigationController should be NavigationController in here?

Copy link
Author

Choose a reason for hiding this comment

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

Not all of our screens that present QR Scanner are coordinators, instead they are simple controllers of MVC patterns. They don't have a way to simply add a coordinator somewhere, so in order to create a unified interface for pushing coordinators without extra work on each file, this looks like a solution:
Now NavigationController now has a property viewControllersToChildCoordinators to hold a reference to coordinators, that could be cleaned up by ARC otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Take a look at the link I shared, it pushed coordinator from the coordinator itself

Copy link
Author

Choose a reason for hiding this comment

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

Maybe we could make a quick call somewhere?

Copy link
Author

Choose a reason for hiding this comment

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

@vikmeup I know what you are talking about, but in our case, we don't always have a coordinator. Take a look on how NewTokenViewController & ImportWalletViewController are created. They don't have coordinators, but somehow, they need to present the QR Scanner. So it seems to me as a viable solution. Please, let me know if I am missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

View controllers can call delegate to the coordinator and you push from the coorditor then, that would be the right way to do it!

Copy link
Author

Choose a reason for hiding this comment

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

I agree. On it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, this is gonna be a big improvement to our codebase once it’s done

* master:
  Change background queue to userInterective when generating QR. (#793)
  Add market price label to token view
  Add Retry button for collectibles
  Version Bump
@vikmeup vikmeup mentioned this pull request Jul 2, 2018
@@ -41,6 +41,9 @@ class BrowserCoordinator: NSObject, Coordinator {
controller.delegate = self
return controller
}()
var providedRootController: UIViewController {
Copy link
Contributor

Choose a reason for hiding this comment

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

why providedRootController? just call it rootViewController?

Copy link
Author

Choose a reason for hiding this comment

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

+, it intersected with the existing name of controllers in some places, but I will just change them as well.

}
}
func popCoordinator(_ coordinator: RootCoordinator, navigationBarHidden: Bool = false) {
if let presentedNVC = providedRootController.presentedViewController as? UINavigationController {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to pop? it should be done automatically once view is closed

@OlegGordiichuk
Copy link
Contributor

@BloodyPixy could you pls resolve conflicts?

* master: (24 commits)
  use WallInfo all over
  Add WalletInfo and WalletObject factory
  Remove mnemonic localization
  Rename mnemonic to phrase
  Add GoChain support
  Add wallet name
  Add import files. Enabled iCloud entitlements
  Fix navigation bar items positioning in browser on iPhone X (#796)
  Upgrade Eureka to 4.2.0
  Add config.yml (#795)
  Use R.string
  Version Bump
  Remove unused items
  Remove GoogleService-Info.plist
  Remove Lokalise framework
  Remove header image on import wallet
  Remove an extra checking
  Remove duplicate value
  Remove extra localization key
  Use R module to fetch localized strings
  ...

# Conflicts:
#	Trust/Browser/Coordinators/BrowserCoordinator.swift
#	Trust/Wallet/ViewControllers/ImportWalletViewController.swift
* master: (24 commits)
  use WallInfo all over
  Add WalletInfo and WalletObject factory
  Remove mnemonic localization
  Rename mnemonic to phrase
  Add GoChain support
  Add wallet name
  Add import files. Enabled iCloud entitlements
  Fix navigation bar items positioning in browser on iPhone X (#796)
  Upgrade Eureka to 4.2.0
  Add config.yml (#795)
  Use R.string
  Version Bump
  Remove unused items
  Remove GoogleService-Info.plist
  Remove Lokalise framework
  Remove header image on import wallet
  Remove an extra checking
  Remove duplicate value
  Remove extra localization key
  Use R module to fetch localized strings
  ...

# Conflicts:
#	Trust/Browser/Coordinators/BrowserCoordinator.swift
#	Trust/Wallet/Coordinators/WalletCoordinator.swift
#	Trust/Wallet/ViewControllers/ImportWalletViewController.swift
…-wallet-ios into bug/push-qr-code-reader

* 'bug/push-qr-code-reader' of github.com:BloodyPixy/trust-wallet-ios:
  Remove trailing whitespace
  Fix for merge issues
  Revert "Removed navigation logic for now"
  Removed navigation logic for now

# Conflicts:
#	Trust/Browser/Coordinators/BrowserCoordinator.swift
#	Trust/UI/NavigationController.swift
#	Trust/Wallet/ViewControllers/ImportWalletViewController.swift
@trust-bot
Copy link

SwiftLint found issues

Warnings

File Line Reason
InCoordinator.swift 75 Function body should span 80 lines or less excluding comments and whitespace: currently spans 85 lines

Generated by 🚫 Danger

@ghost
Copy link
Author

ghost commented Jul 7, 2018

Closing this PR, as there was a lot of discussion and changes involved. Creating new branch for this issue.

@ghost ghost closed this Jul 7, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants