Skip to content

Commit 64c7f20

Browse files
Present support for Authentication protocol method.
1 parent 9e1b510 commit 64c7f20

File tree

1 file changed

+41
-18
lines changed

1 file changed

+41
-18
lines changed

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -376,30 +376,27 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
376376
}
377377
}
378378

379+
/// Presents the Support Interface from a given ViewController, with a specified SourceTag.
380+
///
379381
func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag) {
382+
presentSupport(from: sourceViewController)
380383
}
381384

382-
/// Presents the Support Interface from a given ViewController, with a specified SourceTag.
385+
/// Presents the Support Interface from a given ViewController.
386+
///
387+
/// - Parameters:
388+
/// - from: ViewController from which to present the support interface from
389+
/// - sourceTag: Support source tag of the view controller.
390+
/// - lastStep: Last `Step` tracked in `AuthenticatorAnalyticsTracker`
391+
/// - lastFlow: Last `Flow` tracked in `AuthenticatorAnalyticsTracker`
383392
///
384393
func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag, lastStep: String, lastFlow: String) {
385-
let identifier = HelpAndSupportViewController.classNameWithoutNamespaces
386-
let supportViewController = UIStoryboard.dashboard.instantiateViewController(identifier: identifier,
387-
creator: { coder -> HelpAndSupportViewController? in
388-
guard let customHelpCenterContent = CustomHelpCenterContent(step: lastStep, flow: lastFlow) else {
389-
/// Returning nil as we don't need to customise the HelpAndSupportViewController
390-
/// In this case `instantiateViewController` method will use the default `HelpAndSupportViewController` created from storyboard.
391-
///
392-
return nil
393-
}
394-
395-
return HelpAndSupportViewController(customHelpCenterContent: customHelpCenterContent, coder: coder)
396-
})
397-
supportViewController.displaysDismissAction = true
398-
399-
let navController = WooNavigationController(rootViewController: supportViewController)
400-
navController.modalPresentationStyle = .formSheet
394+
guard let customHelpCenterContent = CustomHelpCenterContent(step: lastStep, flow: lastFlow)else {
395+
presentSupport(from: sourceViewController)
396+
return
397+
}
401398

402-
sourceViewController.present(navController, animated: true, completion: nil)
399+
presentSupport(from: sourceViewController, customHelpCenterContent: customHelpCenterContent)
403400
}
404401

405402
/// Presents the Support new request, from a given ViewController, with a specified SourceTag.
@@ -735,3 +732,29 @@ private extension AuthenticationManager {
735732
return wooAuthError != .unknown
736733
}
737734
}
735+
736+
// MARK: - Help and support helpers
737+
private extension AuthenticationManager {
738+
739+
func presentSupport(from sourceViewController: UIViewController,
740+
customHelpCenterContent: CustomHelpCenterContent? = nil) {
741+
let identifier = HelpAndSupportViewController.classNameWithoutNamespaces
742+
let supportViewController = UIStoryboard.dashboard.instantiateViewController(identifier: identifier,
743+
creator: { coder -> HelpAndSupportViewController? in
744+
guard let customHelpCenterContent = customHelpCenterContent else {
745+
/// Returning nil as we don't need to customise the HelpAndSupportViewController
746+
/// In this case `instantiateViewController` method will use the default `HelpAndSupportViewController` created from storyboard.
747+
///
748+
return nil
749+
}
750+
751+
return HelpAndSupportViewController(customHelpCenterContent: customHelpCenterContent, coder: coder)
752+
})
753+
supportViewController.displaysDismissAction = true
754+
755+
let navController = WooNavigationController(rootViewController: supportViewController)
756+
navController.modalPresentationStyle = .formSheet
757+
758+
sourceViewController.present(navController, animated: true, completion: nil)
759+
}
760+
}

0 commit comments

Comments
 (0)