created a webkit based client for vikunja on ios
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user