mirror of
https://github.com/lumaa-dev/BubbleApp.git
synced 2025-02-03 03:47:43 +01:00
In-App Safari
This commit is contained in:
parent
6150846f24
commit
d2bb747bf9
@ -1,13 +1,29 @@
|
|||||||
//Made by Lumaa
|
//Made by Lumaa
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import UIKit
|
||||||
|
import SafariServices
|
||||||
|
|
||||||
|
/// 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>) {
|
||||||
|
|
||||||
struct SafariView: View {
|
|
||||||
var body: some View {
|
|
||||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
|
||||||
SafariView()
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user