2020#import " flutter/shell/platform/darwin/common/command_line.h"
2121#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h"
2222#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
23+ #import " flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
2324#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h"
2425#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h"
2526#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
@@ -42,7 +43,9 @@ @interface FlutterEngineRegistrar : NSObject <FlutterPluginRegistrar>
4243- (instancetype )initWithPlugin : (NSString *)pluginKey flutterEngine : (FlutterEngine*)flutterEngine ;
4344@end
4445
45- @interface FlutterEngine () <FlutterTextInputDelegate, FlutterBinaryMessenger>
46+ @interface FlutterEngine () <FlutterIndirectScribbleDelegate,
47+ FlutterTextInputDelegate,
48+ FlutterBinaryMessenger>
4649// Maintains a dictionary of plugin names that have registered with the engine. Used by
4750// FlutterEngineRegistrar to implement a FlutterPluginRegistrar.
4851@property (nonatomic , readonly ) NSMutableDictionary * pluginPublications;
@@ -331,6 +334,7 @@ - (void)setViewController:(FlutterViewController*)viewController {
331334
332335- (void )attachView {
333336 self.iosPlatformView ->attachView ();
337+ [_textInputPlugin.get () setupIndirectScribbleInteraction: self .viewController];
334338}
335339
336340- (void )setFlutterViewControllerWillDeallocObserver : (id <NSObject >)observer {
@@ -355,6 +359,7 @@ - (void)notifyViewControllerDeallocated {
355359 platform_view->SetOwnerViewController ({});
356360 }
357361 }
362+ [_textInputPlugin.get () resetViewResponder ];
358363 _viewController.reset ();
359364}
360365
@@ -514,6 +519,8 @@ - (void)setupChannels {
514519
515520 _textInputPlugin.reset ([[FlutterTextInputPlugin alloc ] init ]);
516521 _textInputPlugin.get ().textInputDelegate = self;
522+ _textInputPlugin.get ().indirectScribbleDelegate = self;
523+ [_textInputPlugin.get () setupIndirectScribbleInteraction: self .viewController];
517524
518525 _platformPlugin.reset ([[FlutterPlatformPlugin alloc ] initWithEngine: [self getWeakPtr ]]);
519526
@@ -720,22 +727,30 @@ - (void)notifyLowMemory {
720727
721728#pragma mark - Text input delegate
722729
723- - (void )updateEditingClient : (int )client withState : (NSDictionary *)state {
730+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
731+ updateEditingClient : (int )client
732+ withState : (NSDictionary *)state {
724733 [_textInputChannel.get () invokeMethod: @" TextInputClient.updateEditingState"
725734 arguments: @[ @(client), state ]];
726735}
727736
728- - (void )updateEditingClient : (int )client withState : (NSDictionary *)state withTag : (NSString *)tag {
737+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
738+ updateEditingClient : (int )client
739+ withState : (NSDictionary *)state
740+ withTag : (NSString *)tag {
729741 [_textInputChannel.get () invokeMethod: @" TextInputClient.updateEditingStateWithTag"
730742 arguments: @[ @(client), @{tag : state} ]];
731743}
732744
733- - (void )updateEditingClient : (int )client withDelta : (NSDictionary *)delta {
745+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
746+ updateEditingClient : (int )client
747+ withDelta : (NSDictionary *)delta {
734748 [_textInputChannel.get () invokeMethod: @" TextInputClient.updateEditingStateWithDeltas"
735749 arguments: @[ @(client), delta ]];
736750}
737751
738- - (void )updateFloatingCursor : (FlutterFloatingCursorDragState)state
752+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
753+ updateFloatingCursor : (FlutterFloatingCursorDragState)state
739754 withClient : (int )client
740755 withPosition : (NSDictionary *)position {
741756 NSString * stateString;
@@ -754,7 +769,9 @@ - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
754769 arguments: @[ @(client), stateString, position ]];
755770}
756771
757- - (void )performAction : (FlutterTextInputAction)action withClient : (int )client {
772+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
773+ performAction : (FlutterTextInputAction)action
774+ withClient : (int )client {
758775 NSString * actionString;
759776 switch (action) {
760777 case FlutterTextInputActionUnspecified:
@@ -799,15 +816,63 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client {
799816 arguments: @[ @(client), actionString ]];
800817}
801818
802- - (void )showAutocorrectionPromptRectForStart : (NSUInteger )start
803- end : (NSUInteger )end
804- withClient : (int )client {
819+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
820+ showAutocorrectionPromptRectForStart : (NSUInteger )start
821+ end : (NSUInteger )end
822+ withClient : (int )client {
805823 [_textInputChannel.get () invokeMethod: @" TextInputClient.showAutocorrectionPromptRect"
806824 arguments: @[ @(client), @(start), @(end) ]];
807825}
808826
809827#pragma mark - FlutterViewEngineDelegate
810828
829+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView showToolbar : (int )client {
830+ [_textInputChannel.get () invokeMethod: @" TextInputClient.showToolbar" arguments: @[ @(client) ]];
831+ }
832+
833+ - (void )flutterTextInputPlugin : (FlutterTextInputPlugin*)textInputPlugin
834+ focusElement : (UIScribbleElementIdentifier)elementIdentifier
835+ atPoint : (CGPoint)referencePoint
836+ result : (FlutterResult)callback {
837+ [_textInputChannel.get ()
838+ invokeMethod: @" TextInputClient.focusElement"
839+ arguments: @[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ]
840+ result: callback];
841+ }
842+
843+ - (void )flutterTextInputPlugin : (FlutterTextInputPlugin*)textInputPlugin
844+ requestElementsInRect : (CGRect)rect
845+ result : (FlutterResult)callback {
846+ [_textInputChannel.get ()
847+ invokeMethod: @" TextInputClient.requestElementsInRect"
848+ arguments: @[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ]
849+ result: callback];
850+ }
851+
852+ - (void )flutterTextInputViewScribbleInteractionBegan : (FlutterTextInputView*)textInputView {
853+ [_textInputChannel.get () invokeMethod: @" TextInputClient.scribbleInteractionBegan" arguments: nil ];
854+ }
855+
856+ - (void )flutterTextInputViewScribbleInteractionFinished : (FlutterTextInputView*)textInputView {
857+ [_textInputChannel.get () invokeMethod: @" TextInputClient.scribbleInteractionFinished"
858+ arguments: nil ];
859+ }
860+
861+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
862+ insertTextPlaceholderWithSize : (CGSize)size
863+ withClient : (int )client {
864+ [_textInputChannel.get () invokeMethod: @" TextInputClient.insertTextPlaceholder"
865+ arguments: @[ @(client), @(size.width), @(size.height) ]];
866+ }
867+
868+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
869+ removeTextPlaceholder : (int )client {
870+ [_textInputChannel.get () invokeMethod: @" TextInputClient.removeTextPlaceholder"
871+ arguments: @[ @(client) ]];
872+ }
873+
874+ #pragma mark - Screenshot Delegate
875+
811876- (flutter::Rasterizer::Screenshot)takeScreenshot : (flutter::Rasterizer::ScreenshotType)type
812877 asBase64Encoded : (BOOL )base64Encode {
813878 FML_DCHECK (_shell) << " Cannot takeScreenshot without a shell" ;
0 commit comments