XuqmGroup-iOSSDK/Sources/XuqmWebViewSDK/XWebViewTypes.swift

46 行
1.4 KiB
Swift

2026-05-07 19:39:48 +08:00
import Foundation
import XuqmFileSDK
2026-05-07 19:39:48 +08:00
public struct XWebViewConfig: Sendable {
public var url: String
public var title: String
public var hideToolbar: Bool
public var hideStatusBar: Bool
public var userAgent: String?
public var injectedJavaScript: String?
/// Where intercepted WebView downloads are saved.
public var downloadDestination: FileDownloadDestination
public var onMessage: (@Sendable (String) -> Void)?
2026-05-07 19:39:48 +08:00
public init(
url: String = "",
title: String = "",
hideToolbar: Bool = false,
hideStatusBar: Bool = false,
userAgent: String? = nil,
injectedJavaScript: String? = nil,
downloadDestination: FileDownloadDestination = .sandbox,
onMessage: (@Sendable (String) -> Void)? = nil
2026-05-07 19:39:48 +08:00
) {
self.url = url
self.title = title
self.hideToolbar = hideToolbar
self.hideStatusBar = hideStatusBar
self.userAgent = userAgent
self.injectedJavaScript = injectedJavaScript
self.downloadDestination = downloadDestination
self.onMessage = onMessage
2026-05-07 19:39:48 +08:00
}
}
public protocol XWebViewController: AnyObject {
func canGoBack() -> Bool
func canGoForward() -> Bool
func currentUrl() -> String?
func goBack()
func goForward()
func reload()
func load(url: String)
func postMessageToWeb(js: String)
2026-05-07 19:39:48 +08:00
}