66 lines
1.4 KiB
Swift
66 lines
1.4 KiB
Swift
//
|
|
// WebView.swift
|
|
// TheSwiftWeek
|
|
//
|
|
// Created by Ingo Rohlf on 23.10.25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
import WebKit
|
|
import SafariServices
|
|
|
|
|
|
struct WebAppView: View {
|
|
// @State private var page = WebPage()
|
|
|
|
var body: some View {
|
|
|
|
if let url = URL(string: "https://git.irohlf.de") {
|
|
|
|
if #available(iOS 27.0, *) {
|
|
Text("WebView für iOS 26+")
|
|
WebView(url: url)
|
|
|
|
} else {
|
|
Text("please update to iOS 26.0 or later")
|
|
// WebOldView(url: URL(string: "https://ai.irohlf.de")!)
|
|
SafariView(url: URL(string: "https://cloud.irohlf.de/s/oWYjxWJN9WwJsWq")!)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
struct WebOldView: UIViewRepresentable {
|
|
let url: URL
|
|
//typealias UIViewType = WKWebView
|
|
func makeUIView(context: Context) -> WKWebView {
|
|
.init()
|
|
}
|
|
func updateUIView(_ uiView: WKWebView, context: Context) {
|
|
uiView.load(URLRequest(url: url))
|
|
}
|
|
|
|
}
|
|
|
|
struct SafariView: UIViewControllerRepresentable {
|
|
|
|
let url: URL
|
|
/// typealias UIViewControllerType = SFSafariViewController
|
|
|
|
func makeUIViewController(context: Context) -> SFSafariViewController {
|
|
.init(url: url)
|
|
}
|
|
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#Preview {
|
|
WebAppView()
|
|
}
|