feat(ios): optional tradeoff to fix input delay (#1268)

This commit is contained in:
Andreas Gangsø 2023-05-23 16:54:34 +02:00
parent 2da9db9769
commit d1f5a6721c
3 changed files with 9 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import Foundation
public class FlutterWebViewFactory: NSObject, FlutterPlatformViewFactory { public class FlutterWebViewFactory: NSObject, FlutterPlatformViewFactory {
static let VIEW_TYPE_ID = "com.pichillilorenzo/flutter_inappwebview" static let VIEW_TYPE_ID = "com.pichillilorenzo/flutter_inappwebview"
static let NON_BLOCKING_VIEW_TYPE_ID = "com.pichillilorenzo/flutter_inappwebview_nonblocking"
private var plugin: SwiftFlutterPlugin private var plugin: SwiftFlutterPlugin
init(plugin: SwiftFlutterPlugin) { init(plugin: SwiftFlutterPlugin) {

View File

@ -44,6 +44,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
self.registrar = registrar self.registrar = registrar
registrar.register(FlutterWebViewFactory(plugin: self) as FlutterPlatformViewFactory, withId: FlutterWebViewFactory.VIEW_TYPE_ID) registrar.register(FlutterWebViewFactory(plugin: self) as FlutterPlatformViewFactory, withId: FlutterWebViewFactory.VIEW_TYPE_ID)
registrar.register(FlutterWebViewFactory(plugin: self) as FlutterPlatformViewFactory, withId: FlutterWebViewFactory.NON_BLOCKING_VIEW_TYPE_ID, gestureRecognizersBlockingPolicy:FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded)
platformUtil = PlatformUtil(plugin: self) platformUtil = PlatformUtil(plugin: self)
inAppBrowserManager = InAppBrowserManager(plugin: self) inAppBrowserManager = InAppBrowserManager(plugin: self)

View File

@ -65,6 +65,8 @@ class InAppWebView extends StatefulWidget implements WebView {
///- iOS ///- iOS
final InAppWebViewKeepAlive? keepAlive; final InAppWebViewKeepAlive? keepAlive;
final bool? preventGestureDelay;
///{@macro flutter_inappwebview.InAppWebView} ///{@macro flutter_inappwebview.InAppWebView}
const InAppWebView({ const InAppWebView({
Key? key, Key? key,
@ -187,6 +189,7 @@ class InAppWebView extends StatefulWidget implements WebView {
this.onContentSizeChanged, this.onContentSizeChanged,
this.gestureRecognizers, this.gestureRecognizers,
this.headlessWebView, this.headlessWebView,
this.preventGestureDelay,
}) : super(key: key); }) : super(key: key);
@override @override
@ -799,8 +802,11 @@ class _InAppWebViewState extends State<InAppWebView> {
}, },
); );
} else if (Util.isIOS /* || Util.isMacOS*/) { } else if (Util.isIOS /* || Util.isMacOS*/) {
final viewType = widget.preventGestureDelay == true
? 'com.pichillilorenzo/flutter_inappwebview_nonblocking'
: 'com.pichillilorenzo/flutter_inappwebview';
return UiKitView( return UiKitView(
viewType: 'com.pichillilorenzo/flutter_inappwebview', viewType: viewType,
onPlatformViewCreated: _onPlatformViewCreated, onPlatformViewCreated: _onPlatformViewCreated,
gestureRecognizers: widget.gestureRecognizers, gestureRecognizers: widget.gestureRecognizers,
creationParams: <String, dynamic>{ creationParams: <String, dynamic>{