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
import SwiftUI
import UIKit
import SafariServices
struct SafariView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
/// A SwiftUI representation of SFSafariViewController.
struct SfSafariView: UIViewControllerRepresentable {
/// 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
}
/// Updates the Safari view controller when needed.
/// - 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>) {
}
}
#Preview {
SafariView()
}