* init Signed-off-by: Innei <tukon479@gmail.com> * test uikit Signed-off-by: Innei <tukon479@gmail.com> * uitable Signed-off-by: Innei <tukon479@gmail.com> * test webview Signed-off-by: Innei <tukon479@gmail.com> * shared webview Signed-off-by: Innei <tukon479@gmail.com> * refactor(shared-webview): Simplify WebView height management Signed-off-by: Innei <tukon479@gmail.com> * fix: add url prop Signed-off-by: Innei <tukon479@gmail.com> * rename Signed-off-by: Innei <tukon479@gmail.com> * feat: native module Signed-off-by: Innei <tukon479@gmail.com> * cleanup Signed-off-by: Innei <tukon479@gmail.com> * fix: export Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
//
|
|
// File.swift
|
|
//
|
|
// Created by Innei on 2025/1/29.
|
|
//
|
|
|
|
import ExpoModulesCore
|
|
import WebKit
|
|
|
|
public class SharedWebViewModule: Module {
|
|
public static var sharedWebView: WKWebView? {
|
|
WebViewManager.shared
|
|
}
|
|
|
|
public func definition() -> ModuleDefinition {
|
|
Name("FOSharedWebView")
|
|
|
|
Function("preload") { (url: String) in
|
|
DispatchQueue.main.async {
|
|
guard let webUrl = URL(string: url) else { return }
|
|
let request = URLRequest(url: webUrl)
|
|
WebViewManager.shared.load(request)
|
|
}
|
|
}
|
|
|
|
View(WebViewView.self) {
|
|
Events("onContentHeightChange")
|
|
|
|
Prop("url") { (_: UIView, urlString: String) in
|
|
if let webView = SharedWebViewModule.sharedWebView {
|
|
if let url = URL(string: urlString) {
|
|
if url == webView.url {
|
|
return
|
|
}
|
|
webView.load(URLRequest(url: url))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|