Show QR Code scanner as push view, not modal (#782) #789
Conversation
Black Duck Security ReportMerging #789 into master will not change security risk. |
@BloodyPixy could you pls fix lint warnings. |
@OlegGordiichuk , I am not done yet. |
@OlegGordiichuk , @vikmeup , I have more or less finalized this. In some cases, this is impossible to handle via coordinator, as there in no any. |
@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. |
@BloodyPixy take a look at this: https://irace.me/navigation-coordinators, we only need logic for |
* 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
@vikmeup , check new commits. I believe that's much better and can be applied to all coordinators. |
@BloodyPixy Nice work! I will take another look tomorrow! |
Trust/UI/NavigationController.swift
Outdated
} | ||
} | ||
|
||
protocol RootViewControllerProvider: class { |
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.
can you move into separate file?
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.
Even in two
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.
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) |
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.
navigationController should be NavigationController
in here?
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.
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.
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.
Take a look at the link I shared, it pushed coordinator from the coordinator itself
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.
Maybe we could make a quick call somewhere?
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.
@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.
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.
View controllers can call delegate to the coordinator and you push from the coorditor then, that would be the right way to do it!
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.
I agree. On it.
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.
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
@@ -41,6 +41,9 @@ class BrowserCoordinator: NSObject, Coordinator { | |||
controller.delegate = self | |||
return controller | |||
}() | |||
var providedRootController: UIViewController { |
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.
why providedRootController
? just call it rootViewController
?
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.
+, 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 { |
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.
why do you need to pop? it should be done automatically once view is closed
@BloodyPixy could you pls resolve conflicts? |
This reverts commit 0224982.
* 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
SwiftLint found issuesWarnings
Generated by 🚫 Danger |
Closing this PR, as there was a lot of discussion and changes involved. Creating new branch for this issue. |
@vikmeup , referencing #782 issue. I have started to alter the code. I have moved logic for creating and navigating QR Code scanner from
SendViewController
toSendCoordinator
, 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.