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

SafariViewController auth screen blank if presented from inside a SwiftUI ScrollView #266

Closed
jnpdx opened this issue Mar 25, 2020 · 4 comments

Comments

@jnpdx
Copy link

jnpdx commented Mar 25, 2020

I don't know that this is a bug that the Dropbox team can fix as it may just be an issue inherent to SwiftUI, but I thought I'd write up an issue that others may finding searching since it caught me for a couple of hours this morning until I figured it out.

If the auth flow is initiated from SwiftUI, if the UIViewController passed to the DropboxClientsManager resides in a ScrollView, the resulting SafariViewController won't load the Dropbox page. It'll either be completely blank, or uninitialized (eg just say "Website name" at the top).

Here's reproducible code (iOS 13.4) -- note that removing the ScrollView from ContentView solves the problem:

struct ContentView : View {
    @State var isShown = false
    
    var body : some View {
        ScrollView {
            VStack {
                Text("HI!")
                Button(action: {
                    self.isShown.toggle()
                }) {
                    Text("Dropbox....")
                }
                DropboxView(isShown: $isShown)
            }
        }
    }
}


struct DropboxView: UIViewControllerRepresentable {
    typealias UIViewControllerType = UIViewController
    
    @Binding var isShown : Bool

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
        if isShown {
            DropboxClientsManager.authorizeFromController(UIApplication.shared,
            controller: uiViewController,
            openURL: { (url: URL) -> Void in
                UIApplication.shared.open(url, options: [:], completionHandler: nil)
            })
        }
    }

    func makeUIViewController(context _: Self.Context) -> UIViewController {
        return UIViewController()
    }
}

@greg-db
Copy link
Contributor

greg-db commented Mar 25, 2020

Thanks for writing this up! I'll ask the team to take a look over this in case this is something we can fix on our side.

Also, in case it's relevant, I noticed this in the console when reproducing this with the ScrollView:

Presenting view controllers on detached view controllers is discouraged <UIViewController: 0x7fe9f3804430>.

@amoshsueh
Copy link

I can't believe that after more than one year there is still no support for SwiftUI, this should be a basic requirement to be a SDK for development.

@greg-db
Copy link
Contributor

greg-db commented Aug 6, 2021

Thanks for the feedback!

@greg-db
Copy link
Contributor

greg-db commented Oct 12, 2022

The team has updated SwiftyDropbox to support SwiftUI in the latest version of the SDK (v9.1.0). Let us know if you try that and run in to any issues. Thanks!

@greg-db greg-db closed this as completed Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@jnpdx @amoshsueh @greg-db and others