Flutter iOS Embedder
FlutterTouchInterceptingView Class Reference

#import <FlutterPlatformViews_Internal.h>

Inheritance diagram for FlutterTouchInterceptingView:

Instance Methods

(instancetype) - initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:
 
(void) - releaseGesture
 
(void) - blockGesture
 
(UIView *) - embeddedView
 
(id) - accessibilityContainer
 

Properties

id flutterAccessibilityContainer
 

Detailed Description

Definition at line 138 of file FlutterPlatformViews_Internal.h.

Method Documentation

◆ accessibilityContainer

- (id) accessibilityContainer

Provided by category FlutterTouchInterceptingView(Tests).

◆ blockGesture

- (void) blockGesture

Definition at line 571 of file FlutterPlatformViews_Internal.mm.

571  {
572  switch (_blockingPolicy) {
574  // We block all other gesture recognizers immediately in this policy.
575  self.delayingRecognizer.state = UIGestureRecognizerStateEnded;
576 
577  // On iOS 18.2, WKWebView's internal recognizer likely caches the old state of its blocking
578  // recognizers (i.e. delaying recognizer), resulting in non-tappable links. See
579  // https://github.com/flutter/flutter/issues/158961. Removing and adding back the delaying
580  // recognizer solves the problem, possibly because UIKit notifies all the recognizers related
581  // to (blocking or blocked by) this recognizer. It is not possible to inject this workaround
582  // from the web view plugin level. Right now we only observe this issue for
583  // FlutterPlatformViewGestureRecognizersBlockingPolicyEager, but we should try it if a similar
584  // issue arises for the other policy.
585  if (@available(iOS 18.2, *)) {
586  // This workaround is designed for WKWebView only. The 1P web view plugin provides a
587  // WKWebView itself as the platform view. However, some 3P plugins provide wrappers of
588  // WKWebView instead. So we perform DFS to search the view hierarchy (with a depth limit).
589  // Passing a limit of 0 means only searching for platform view itself; Pass 1 to include its
590  // children as well, and so on. We should be conservative and start with a small number. The
591  // AdMob banner has a WKWebView at depth 7.
592  if ([self containsWebView:self.embeddedView remainingSubviewDepth:1]) {
593  [self removeGestureRecognizer:self.delayingRecognizer];
594  [self addGestureRecognizer:self.delayingRecognizer];
595  }
596  }
597 
598  break;
600  if (self.delayingRecognizer.touchedEndedWithoutBlocking) {
601  // If touchesEnded of the `DelayingGesureRecognizer` has been already invoked,
602  // we want to set the state of the `DelayingGesureRecognizer` to
603  // `UIGestureRecognizerStateEnded` as soon as possible.
604  self.delayingRecognizer.state = UIGestureRecognizerStateEnded;
605  } else {
606  // If touchesEnded of the `DelayingGesureRecognizer` has not been invoked,
607  // We will set a flag to notify the `DelayingGesureRecognizer` to set the state to
608  // `UIGestureRecognizerStateEnded` when touchesEnded is called.
609  self.delayingRecognizer.shouldEndInNextTouchesEnded = YES;
610  }
611  break;
612  default:
613  break;
614  }
615 }

References embeddedView, FlutterPlatformViewGestureRecognizersBlockingPolicyEager, and FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded.

◆ embeddedView

◆ initWithEmbeddedView:platformViewsController:gestureRecognizersBlockingPolicy:

- (instancetype) initWithEmbeddedView: (UIView*)  embeddedView
platformViewsController: (fml::WeakPtr<flutter::PlatformViewsController>)  platformViewsController
gestureRecognizersBlockingPolicy: (FlutterPlatformViewGestureRecognizersBlockingPolicy blockingPolicy 

Definition at line 522 of file FlutterPlatformViews_Internal.mm.

522  :(UIView*)embeddedView
523  platformViewsController:
524  (fml::WeakPtr<flutter::PlatformViewsController>)platformViewsController
525  gestureRecognizersBlockingPolicy:
527  self = [super initWithFrame:embeddedView.frame];
528  if (self) {
529  self.multipleTouchEnabled = YES;
530  _embeddedView = embeddedView;
531  embeddedView.autoresizingMask =
532  (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
533 
534  [self addSubview:embeddedView];
535 
536  ForwardingGestureRecognizer* forwardingRecognizer =
537  [[ForwardingGestureRecognizer alloc] initWithTarget:self
538  platformViewsController:platformViewsController];
539 
540  _delayingRecognizer =
541  [[FlutterDelayingGestureRecognizer alloc] initWithTarget:self
542  action:nil
543  forwardingRecognizer:forwardingRecognizer];
544  _blockingPolicy = blockingPolicy;
545 
546  [self addGestureRecognizer:_delayingRecognizer];
547  [self addGestureRecognizer:forwardingRecognizer];
548  }
549  return self;
550 }

References embeddedView.

◆ releaseGesture

- (void) releaseGesture

Definition at line 552 of file FlutterPlatformViews_Internal.mm.

552  {
553  self.delayingRecognizer.state = UIGestureRecognizerStateFailed;
554 }

Property Documentation

◆ flutterAccessibilityContainer

- (id) flutterAccessibilityContainer
readwritenonatomicretain

Definition at line 155 of file FlutterPlatformViews_Internal.h.


The documentation for this class was generated from the following files:
-[FlutterTouchInterceptingView embeddedView]
UIView * embeddedView()
FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded
@ FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded
Definition: FlutterPlugin.h:269
FlutterDelayingGestureRecognizer
Definition: FlutterPlatformViews_Internal.h:169
ForwardingGestureRecognizer
Definition: FlutterPlatformViews_Internal.h:196
FlutterPlatformViewGestureRecognizersBlockingPolicyEager
@ FlutterPlatformViewGestureRecognizersBlockingPolicyEager
Definition: FlutterPlugin.h:261
FlutterPlatformViewGestureRecognizersBlockingPolicy
FlutterPlatformViewGestureRecognizersBlockingPolicy
Definition: FlutterPlugin.h:252