2018-11-13 11:02:20 +00:00
|
|
|
//
|
|
|
|
// FlutterWebViewFactory.swift
|
2019-11-29 15:59:18 +00:00
|
|
|
// flutter_inappwebview
|
2018-11-13 11:02:20 +00:00
|
|
|
//
|
|
|
|
// Created by Lorenzo on 13/11/18.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Flutter
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
public class FlutterWebViewFactory: NSObject, FlutterPlatformViewFactory {
|
2022-05-05 18:19:16 +00:00
|
|
|
static let VIEW_TYPE_ID = "com.pichillilorenzo/flutter_inappwebview"
|
2019-10-26 02:42:50 +00:00
|
|
|
private var registrar: FlutterPluginRegistrar?
|
2018-11-13 11:02:20 +00:00
|
|
|
|
|
|
|
init(registrar: FlutterPluginRegistrar?) {
|
|
|
|
super.init()
|
|
|
|
self.registrar = registrar
|
|
|
|
}
|
|
|
|
|
|
|
|
public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
|
|
|
|
return FlutterStandardMessageCodec.sharedInstance()
|
|
|
|
}
|
|
|
|
|
|
|
|
public func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> FlutterPlatformView {
|
|
|
|
let arguments = args as? NSDictionary
|
2022-10-20 14:34:37 +00:00
|
|
|
|
|
|
|
if let headlessWebViewId = arguments?["headlessWebViewId"] as? String,
|
|
|
|
let headlessWebView = HeadlessInAppWebViewManager.webViews[headlessWebViewId],
|
|
|
|
let platformView = headlessWebView?.disposeAndGetFlutterWebView(withFrame: frame) {
|
|
|
|
return platformView
|
|
|
|
}
|
|
|
|
|
2019-10-26 02:42:50 +00:00
|
|
|
let webviewController = FlutterWebViewController(registrar: registrar!,
|
|
|
|
withFrame: frame,
|
|
|
|
viewIdentifier: viewId,
|
2021-03-26 20:04:44 +00:00
|
|
|
params: arguments!)
|
|
|
|
webviewController.makeInitialLoad(params: arguments!)
|
2018-11-13 11:02:20 +00:00
|
|
|
return webviewController
|
|
|
|
}
|
|
|
|
}
|