created a webkit based client for vikunja on ios

This commit is contained in:
2026-03-13 21:45:16 +01:00
parent 4aa0d808ac
commit d76b12ffe4
7 changed files with 143 additions and 26 deletions
+43
View File
@@ -0,0 +1,43 @@
//
// WebView.swift
// VikunjaApp
//
// Created by Justin Schwegmann on 13.03.26.
//
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
let url: URL
@Binding var canGoBack: Bool
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIView(context: Context) -> WKWebView {
let config = WKWebViewConfiguration()
config.websiteDataStore = WKWebsiteDataStore.default() // persistent auf Disk
let webView = WKWebView(frame: .zero, configuration: config)
webView.navigationDelegate = context.coordinator
webView.allowsBackForwardNavigationGestures = true
context.coordinator.webView = webView
webView.load(URLRequest(url: url))
return webView
}
func updateUIView(_ webView: WKWebView, context: Context) {}
class Coordinator: NSObject, WKNavigationDelegate {
var parent: WebView
var webView: WKWebView?
init(_ parent: WebView) { self.parent = parent }
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
parent.canGoBack = webView.canGoBack
}
}
}