docusign / native-ios-sdk

A set of official UI components along with programmable client libraries that enable developers to integrate their products with DocuSign’s signature service API on iOS
https://docusign.github.io/native-ios-sdk/documentation/docusignsdk/
Other
28 stars 27 forks source link

NavigationBar appearance changing while calling DSMManager.login() method #130

Closed JacobVnu closed 9 months ago

JacobVnu commented 2 years ago

Hi Am using Docusign V 2.11. In my application Am setting my NavigationBar theme in AppDelegate didfinsihLaunching method. And Am calling the method, DSMManager.login() in home page. After this method called, if I try to presenting any viewController with viewController.modalPresentationStyle = .fullScreen and come back to previous page by dismissing it, my NavigationBar color changed to white color.

For reference you can see the following test code snippets.

Step 1: Setting NavigationBar color to red.

Step 2: Pushing FirstViewController and Navigate back and Presenting SecondViewController and dismissing. Observing the NvigationBar color and it is in Red.

    @IBAction func pushClicked(_ sender: Any) {
        let firstVC = self.storyboard?.instantiateViewController(withIdentifier: "FirstViewController") as! FirstViewController
        self.navigationController?.pushViewController(firstVC, animated: true)
    }
    @IBAction func presentClicked(_ sender: Any) {
        let secondVC = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
        secondVC.modalPresentationStyle = .fullScreen
        self.present(secondVC, animated: true)
    }

Step3: Calling DSMManager.login()

@IBAction func callLogin(_ sender: Any) {
        let host = "https://demo.docusign.net/restapi"
        guard let hostURL = URL(string: host) else { return }
        DSMManager.login(withAccessToken: "accessToken", accountId: "accountId", userId: "userId", userName: "userName", email: "email", host: hostURL, integratorKey: "integratorKey") { [weak self] accountInfo, error in
            if let error = error {
                print("Error logging in: \(error)")
            } else {
                print("User authenticated")
            }
        }
    }

Step 4: Repeat Step 2. Now we can see that the NavigationBar color changed to white.

Sample App URL: https://github.com/JacobVnu/DocuSign-Demo

mmohareb commented 2 years ago

Hello @JacobVnu

Thanks for the details and Sample app, it seems the issue is related to how you set the navbar color, setting it in AppDelegate does not maintain it across screens, basically when you show a new ViewController that removes the navigation bar, when it's re added again it doesn't maintain the same color. I was able to avoid this issue, by moving the nav bar code from App delegate to the HomeViewController viewWillAppear, this will maintain the red color across navigation steps.

 override func viewWillAppear(_ animated: Bool) {
        let appearance = UINavigationBarAppearance()
        appearance.configureWithTransparentBackground()
        appearance.backgroundColor = .red
        appearance.titleTextAttributes = [
            NSAttributedString.Key.foregroundColor: UIColor.white,
            NSAttributedString.Key.font: UIFont.systemFont(ofSize: 12.0)
        ]
        UINavigationBar.appearance().tintColor = .white
        UINavigationBar.appearance().standardAppearance = appearance
        UINavigationBar.appearance().scrollEdgeAppearance = appearance
    }

Let us know if we can help from our side.

JacobVnu commented 2 years ago

Hi @mmohareb

Thank you for your reply. The App has a feature that, if we set the AppTheme in didFinishLaunching() it will apply to entire app. And we don't need to reapply it again. The App was working well and it shows the NavigationBar color in all viewControllers. The issue start happening after the DocuSign SDK update into V 2.12. And we identified that the issue happening only after calling the DSMManager.login() function.

keenan-chiasson commented 1 year ago

Any progress on this? I do not set the navbar's color anywhere and after calling DSMManager.login() my app's navbar turns white and gives a docusign-blue background when scrolled.

becknaum commented 1 year ago

I was able to avoid this issue, by moving the nav bar code from App delegate to the HomeViewController viewWillAppear, this will maintain the red color across navigation steps.

This is a workaround, it is not a resolution. I have an app that changes navigation bar appearance in AppDelegate for convenience, global UI consistency, and to support light and dark mode changes.

I do not set the navbar's color anywhere and after calling DSMManager.login() my app's navbar turns white and gives a docusign-blue background when scrolled.

I am seeing this same behavior, but I am not calling DSMManager.login(), only the following set up code is changing the nav bar appearance:

var configurations = DSMManager.defaultConfigurations() configurations[DSM_SETUP_POWERED_BY_DOCUSIGN_ENABLED] = DSM_SETUP_FALSE_VALUE configurations[DSM_SETUP_ONLINE_SIGNING_DISABLE_NATIVE_COMPONENTS] = DSM_SETUP_TRUE_VALUE DSMManager.setup(withConfiguration: configurations)

My question is-- why does this change the nav bar appearance at all? Regardless of where we update the nav bar appearance, I expect a third-party SDK to leave that alone until the point any actual UI code is invoked. If that is part of the default configuration, then it should be disabled by default.

mmohareb commented 1 year ago

Hello Thanks for the feedback, we have reopened this issue to investigate the issue of changing the navigation bar color even if no UI was presented. Will investigate into this issue and try to see if/when we can address this concern. For now as recommended before please use the UIViewController delegate to update the navigation bar as this will ensure a consistent behavior, there can always be a (Base)UIViewController that all UIViewController inherit from where all of the mentioned changes can be handled easily without code duplication.

keenan-chiasson commented 10 months ago

Any movement on this?

mmohareb commented 10 months ago

Hello @keenan-chiasson we are trying to get this in for the next release (Planned end of this month) if not will try to have a quick follow up with a dot release for this one.

mmohareb commented 9 months ago

Issue fixed in https://github.com/docusign/native-ios-sdk/releases/tag/v3.2.0

Seify commented 3 months ago

It's not completely fixed. If I do on the first launch

        var configurations = DSMManager.defaultConfigurations()
        configurations[DSM_SETUP_DISABLE_APPEARANCE] = DSM_SETUP_TRUE_VALUE
        DSMManager.setup(withConfiguration: configurations)

then it still changes the color of navbar. HOWEWER, if I do:

        DSMManager.setConfigurationValue(DSM_SETUP_TRUE_VALUE, key: DSM_SETUP_DISABLE_APPEARANCE)

        var configurations = DSMManager.defaultConfigurations()
        configurations[DSM_SETUP_DISABLE_APPEARANCE] = DSM_SETUP_TRUE_VALUE
        DSMManager.setup(withConfiguration: configurations)

it works

Seify commented 3 months ago

@mmohareb