Fix nav bars during registration & change number
The new OWSNavigationController design handles showing/hiding the nav bar. The code in this class was fighting against it, which caused the nav bars to appear/disappear unexpectedly throughout the process. The vc.navigationController.navigationItem.backBarButtonItem.isEnabled code also appears to be a no-op. A view controller should configure its own navigationItem (ie vc.navigationItem), not that of its navigationController. Furthermore, backBarButtonItem isn't set to what's actually shown -- this is an opportunity to override what should be shown to our own custom button.
This commit is contained in:
parent
578862f04b
commit
570e591ae3
@ -58,12 +58,9 @@ extension ChangePhoneNumberCaptchaViewController: RegistrationCaptchaViewControl
|
||||
|
||||
changePhoneNumberController.requestVerification(fromViewController: self, isSMS: true) { [weak self] willDismiss, _ in
|
||||
|
||||
if let self = self,
|
||||
!willDismiss {
|
||||
RegistrationBaseViewController.restoreBackButton(self)
|
||||
|
||||
// There's nothing left to do here. If onboardingController isn't taking us anywhere, let's
|
||||
// just pop back to the phone number verification controller
|
||||
if let self = self, !willDismiss {
|
||||
// There's nothing left to do here. If onboardingController isn't taking us
|
||||
// anywhere, let's just pop back to the phone number confirm controller
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
}
|
||||
viewModel.removeProgressView(progressView)
|
||||
|
||||
@ -128,8 +128,6 @@ class ChangePhoneNumberController: Dependencies {
|
||||
return
|
||||
}
|
||||
|
||||
RegistrationBaseViewController.restoreBackButton(changePhoneNumberViewFromViewController)
|
||||
|
||||
if didSucceed {
|
||||
guard let newPhoneNumber = newPhoneNumber else {
|
||||
owsFailDebug("Missing new number.")
|
||||
|
||||
@ -63,11 +63,6 @@ public class ChangePhoneNumberVerificationViewController: RegistrationBaseViewCo
|
||||
|
||||
// MARK: - Methods
|
||||
|
||||
@objc
|
||||
public func hideBackLink() {
|
||||
backLink?.isHidden = true
|
||||
}
|
||||
|
||||
@objc
|
||||
public func setVerificationCodeAndTryToVerify(_ verificationCode: String) {
|
||||
AssertIsOnMainThread()
|
||||
@ -137,8 +132,6 @@ extension ChangePhoneNumberVerificationViewController: RegistrationVerificationV
|
||||
|
||||
Logger.info("")
|
||||
|
||||
RegistrationBaseViewController.restoreBackButton(self)
|
||||
|
||||
let phoneNumberVC = navigationController?.viewControllers
|
||||
.filter { $0 is ChangePhoneNumberSplashViewController }.last
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
import UIKit
|
||||
|
||||
@objc
|
||||
public class RegistrationBaseViewController: OWSViewController {
|
||||
public class RegistrationBaseViewController: OWSViewController, OWSNavigationChildController {
|
||||
|
||||
// MARK: - Factory Methods
|
||||
|
||||
@ -109,34 +109,12 @@ public class RegistrationBaseViewController: OWSViewController {
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
@objc
|
||||
public var shouldHideBackButton = true
|
||||
|
||||
public override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
if shouldHideBackButton {
|
||||
Self.hideBackButton(self)
|
||||
}
|
||||
public var prefersNavigationBarHidden: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
public override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
if shouldHideBackButton {
|
||||
Self.hideBackButton(self)
|
||||
}
|
||||
}
|
||||
|
||||
public static func hideBackButton(_ vc: UIViewController) {
|
||||
vc.navigationController?.isNavigationBarHidden = true
|
||||
// Disable "back" gesture.
|
||||
vc.navigationController?.navigationItem.backBarButtonItem?.isEnabled = false
|
||||
}
|
||||
|
||||
public static func restoreBackButton(_ vc: UIViewController) {
|
||||
vc.navigationController?.isNavigationBarHidden = false
|
||||
vc.navigationController?.navigationItem.backBarButtonItem?.isEnabled = true
|
||||
public var shouldCancelNavigationBack: Bool {
|
||||
true
|
||||
}
|
||||
|
||||
// The margins for `primaryView` will update to reflect the current traitCollection.
|
||||
|
||||
@ -51,7 +51,6 @@ public class ProvisioningController: NSObject {
|
||||
navController.setViewControllers([vc], animated: false)
|
||||
|
||||
provisioningController.awaitProvisioning(from: vc, navigationController: navController)
|
||||
navController.isNavigationBarHidden = true
|
||||
CurrentAppContext().mainWindow?.rootViewController = navController
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,6 @@ public extension RegistrationUtils {
|
||||
viewController.hideBackLink()
|
||||
let navigationController = OnboardingNavigationController(onboardingController: onboardingController)
|
||||
navigationController.setViewControllers([ viewController ], animated: false)
|
||||
navigationController.isNavigationBarHidden = true
|
||||
let window: UIWindow = CurrentAppContext().mainWindow!
|
||||
window.rootViewController = navigationController
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user