diff --git a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate index 5fbe364..1c43ec6 100644 Binary files a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate and b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/WebAppView.swift b/WebAppView.swift index 41acd6d..c1f377a 100644 --- a/WebAppView.swift +++ b/WebAppView.swift @@ -10,28 +10,88 @@ import SwiftUI import WebKit import SafariServices - -struct WebAppView: View { -// @State private var page = WebPage() +struct LoadingWebView: View { + @State private var isLoading = true var body: some View { - - if let url = URL(string: "https://git.irohlf.de") { - - if #available(iOS 27.0, *) { + ZStack { + if #available(iOS 26.0, *) { + WebGitView { isLoading = false } + } else { + // Fallback on earlier versions + } + if isLoading { ProgressView() } + } + } +} + + +struct WebAppView: View { + // @State private var page = WebPage() + + + var body: some View { + + if let url = URL(string: "https://minecraft.irohlf.de") { + + if #available(iOS 26.0, *) { Text("WebView für iOS 26+") - WebView(url: url) + WebGitView{ + } + } else { Text("please update to iOS 26.0 or later") -// WebOldView(url: URL(string: "https://ai.irohlf.de")!) + // WebOldView(url: URL(string: "https://ai.irohlf.de")!) SafariView(url: URL(string: "https://cloud.irohlf.de/s/oWYjxWJN9WwJsWq")!) - } + } + } +} +@available(iOS 26.0, *) +struct WebGitView: UIViewRepresentable { + + + func makeCoordinator() -> Coordinator { + Coordinator(parent: self) + } + let url: URL = URL(string: "https://git.irohlf.de")! + var completion: () -> Void + + //typealias UIViewType = WKWebView + func makeUIView(context: Context) -> WKWebView { + let webView = WKWebView() + webView.navigationDelegate = context.coordinator + return webView + } + + + func updateUIView(_ uiView: WKWebView, context: Context) { + uiView.load(URLRequest(url: url)) + } + + @available(iOS 26.0, *) + class Coordinator: NSObject, WKNavigationDelegate { + var parent: WebGitView + init(parent: WebGitView ) { + self.parent = parent } + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + print("Fertsch geladen") + } + func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { + print("Bin laden") + } + + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + + + } } + } struct WebOldView: UIViewRepresentable { @@ -58,9 +118,9 @@ struct SafariView: UIViewControllerRepresentable { } } - + #Preview { - WebAppView() + LoadingWebView() }