Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Skip button in Link signup pane instead of close #4244

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ extension FinancialConnectionsNavigationController {

static func configureNavigationItemForNative(
_ navigationItem: UINavigationItem?,
closeItem: UIBarButtonItem,
trailingItem: UIBarButtonItem,
shouldHideLogo: Bool,
theme: FinancialConnectionsTheme,
isTestMode: Bool
Expand Down Expand Up @@ -212,6 +212,6 @@ extension FinancialConnectionsNavigationController {

navigationItem?.titleView = stackView
navigationItem?.backButtonTitle = ""
navigationItem?.rightBarButtonItem = closeItem
navigationItem?.rightBarButtonItem = trailingItem
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ class NativeFlowController {
return item
}()

private lazy var navigationBarSkipBarButtonItem: UIBarButtonItem = {
let item = UIBarButtonItem(
title: STPLocalizedString("Skip", "Title of a button that allows users to skip the current screen."),
style: .plain,
target: self,
action: #selector(didSelectNavigationBarSkipButton)
)
let attributes: [NSAttributedString.Key: Any] = [
.font: FinancialConnectionsFont.label(.large).uiFont,
.foregroundColor: UIColor.textDefault,
]
item.setTitleTextAttributes(attributes, for: .normal)
return item
}()

init(
dataManager: NativeFlowDataManager,
navigationController: FinancialConnectionsNavigationController
Expand Down Expand Up @@ -82,7 +97,11 @@ class NativeFlowController {
// then also handle "custom manual entry mode"
closeAuthFlow(customManualEntry: true)
} else {
setNavigationControllerViewControllers([viewController], animated: false)
setNavigationControllerViewControllers(
[viewController],
pane: pane,
animated: false
)
}
}

Expand Down Expand Up @@ -117,6 +136,16 @@ class NativeFlowController {
}
}

@objc private func didSelectNavigationBarSkipButton() {
FeedbackGeneratorAdapter.buttonTapped()
dataManager.analyticsClient.log(
eventName: "click.nav_bar.skip",
pane: FinancialConnectionsAnalyticsClient
.paneFromViewController(navigationController.topViewController)
)
pushPane(.success, animated: true)
}

@objc private func applicationWillEnterForeground() {
dataManager
.analyticsClient
Expand All @@ -136,6 +165,13 @@ class NativeFlowController {
.paneFromViewController(navigationController.topViewController)
)
}

private func trailingItem(forPane pane: FinancialConnectionsSessionManifest.NextPane) -> UIBarButtonItem {
switch pane {
case .networkingLinkSignupPane: navigationBarSkipBarButtonItem
default: navigationBarCloseBarButtonItem
}
}
}

// MARK: - Core Navigation Helpers
Expand All @@ -144,14 +180,15 @@ extension NativeFlowController {

private func setNavigationControllerViewControllers(
_ viewControllers: [UIViewController],
pane: FinancialConnectionsSessionManifest.NextPane,
animated: Bool = true
) {
dismissVisibleSheetsIfNeeded { [weak self] in
guard let self else { return }
viewControllers.forEach { viewController in
FinancialConnectionsNavigationController.configureNavigationItemForNative(
viewController.navigationItem,
closeItem: self.navigationBarCloseBarButtonItem,
trailingItem: self.trailingItem(forPane: pane),
shouldHideLogo: ShouldHideLogoInNavigationBar(
forViewController: viewController,
reducedBranding: self.dataManager.reducedBranding,
Expand Down Expand Up @@ -187,20 +224,32 @@ extension NativeFlowController {
dataManager: dataManager
)
if clearNavigationStack, let paneViewController = paneViewController {
setNavigationControllerViewControllers([paneViewController], animated: animated)
setNavigationControllerViewControllers(
[paneViewController],
pane: pane,
animated: animated
)
} else {
pushViewController(paneViewController, animated: animated)
pushViewController(
paneViewController,
pane: pane,
animated: animated
)
}
}
}

private func pushViewController(_ viewController: UIViewController?, animated: Bool) {
private func pushViewController(
_ viewController: UIViewController?,
pane: FinancialConnectionsSessionManifest.NextPane,
animated: Bool
) {
dismissVisibleSheetsIfNeeded { [weak self] in
guard let self else { return }
if let viewController = viewController {
FinancialConnectionsNavigationController.configureNavigationItemForNative(
viewController.navigationItem,
closeItem: self.navigationBarCloseBarButtonItem,
trailingItem: self.trailingItem(forPane: pane),
shouldHideLogo: ShouldHideLogoInNavigationBar(
forViewController: viewController,
reducedBranding: self.dataManager.reducedBranding,
Expand Down Expand Up @@ -283,9 +332,10 @@ extension NativeFlowController {
}

private func startResetFlow() {
let pane: FinancialConnectionsSessionManifest.NextPane = .resetFlow
guard
let resetFlowViewController = CreatePaneViewController(
pane: .resetFlow,
pane: pane,
nativeFlowController: self,
dataManager: dataManager
)
Expand All @@ -303,7 +353,11 @@ extension NativeFlowController {
}
viewControllers.append(resetFlowViewController)

setNavigationControllerViewControllers(viewControllers, animated: true)
setNavigationControllerViewControllers(
viewControllers,
pane: pane,
animated: true
)
}

private func showTerminalError(_ error: Error? = nil) {
Expand Down Expand Up @@ -331,7 +385,11 @@ extension NativeFlowController {
closeAuthFlow(error: terminalError)
return
}
setNavigationControllerViewControllers([terminalErrorViewController], animated: false)
setNavigationControllerViewControllers(
[terminalErrorViewController],
pane: .terminalError,
animated: false
)
}

// There's at least four types of close cases:
Expand Down
Loading