In-App Safari

This commit is contained in:
Lumaa 2024-01-21 13:07:50 +01:00
parent 6150846f24
commit d2bb747bf9

View File

@ -1,13 +1,29 @@
//Made by Lumaa //Made by Lumaa
import SwiftUI import SwiftUI
import UIKit
import SafariServices
struct SafariView: View { /// A SwiftUI representation of SFSafariViewController.
var body: some View { struct SfSafariView: UIViewControllerRepresentable {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) /// The URL to be opened in the Safari view.
} let url: URL
/// Creates and returns a new instance of SFSafariViewController.
/// - Parameter context: The context in which the Safari view controller is being created.
/// - Returns: An instance of SFSafariViewController with the specified URL.
func makeUIViewController(context: UIViewControllerRepresentableContext<SfSafariView>) -> SFSafariViewController {
let safari = SFSafariViewController(url: url)
safari.preferredControlTintColor = UIColor.white
return safari
} }
#Preview { /// Updates the Safari view controller when needed.
SafariView() /// - Parameters:
/// - uiViewController: The existing SFSafariViewController instance.
/// - context: The context in which the Safari view controller is being updated.
func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SfSafariView>) {
}
} }