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

Configuration on NaiveSafariView #2

Closed
yixe opened this issue Aug 22, 2020 · 4 comments
Closed

Configuration on NaiveSafariView #2

yixe opened this issue Aug 22, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@yixe
Copy link

yixe commented Aug 22, 2020

It seems there is no way to configure NaiveSafariView at the moment.
For example to add entersReaderIfAvailable: true to a sheet that has NaiveSafariView as its content.

@stleamist
Copy link
Owner

Hi @yixe,

NaiveSafariView has been implemented just to demonstrate common problems of well-known workarounds, not to be used in practice. It was designed on purpose to have no functionality.

If you're keen to use it for your project, however, you can make your own NaiveSafariView like this:

import SwiftUI
import SafariServices

struct NaiveSafariView: UIViewControllerRepresentable {
    
    var url: URL
    var configuration: SFSafariViewController.Configuration = .init()
    
    func makeUIViewController(context: Context) -> SFSafariViewController {
        SFSafariViewController(url: url, configuration: configuration)
    }
    
    func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
        
    }
}

@stleamist stleamist added the wontfix This will not be worked on label Aug 23, 2020
@yixe
Copy link
Author

yixe commented Aug 23, 2020

Oh I see, how would you go about putting a SafariView inside a sheet/fullscreencover, It seem to always hit back with Static method 'buildBlock' requires that 'SafariView' conform to 'View'

@stleamist stleamist reopened this Aug 24, 2020
@stleamist stleamist removed the wontfix This will not be worked on label Aug 24, 2020
@stleamist
Copy link
Owner

For the moment, you need to implement something like NaiveSafariView to use on SwiftUI native view modifiers. It's because the current version of SafariView is actually not a View but just a simple struct used for internal SafariViewHosting.

Its View conformance had been implemented during the preparation process of v2.0.0 update, but was removed just before the release(c8a0d7e) due to some concerns about project complexity.

For the use cases you mentioned, I’ll release a new update soon that adds View conformance to the SafariView.

Thank you for pointing out this case. 😃

@stleamist stleamist self-assigned this Aug 24, 2020
@stleamist stleamist added the enhancement New feature or request label Aug 24, 2020
@stleamist
Copy link
Owner

Starting from v2.2.0, you can now pass the SafariView as a View to the .sheet() and .fullScreenCover() modifiers.

Thank you for your contribution. 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants