20
20
#import " flutter/shell/platform/darwin/common/command_line.h"
21
21
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h"
22
22
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
23
+ #import " flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
23
24
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h"
24
25
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h"
25
26
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
@@ -42,7 +43,9 @@ @interface FlutterEngineRegistrar : NSObject <FlutterPluginRegistrar>
42
43
- (instancetype )initWithPlugin : (NSString *)pluginKey flutterEngine : (FlutterEngine*)flutterEngine ;
43
44
@end
44
45
45
- @interface FlutterEngine () <FlutterTextInputDelegate, FlutterBinaryMessenger>
46
+ @interface FlutterEngine () <FlutterIndirectScribbleDelegate,
47
+ FlutterTextInputDelegate,
48
+ FlutterBinaryMessenger>
46
49
// Maintains a dictionary of plugin names that have registered with the engine. Used by
47
50
// FlutterEngineRegistrar to implement a FlutterPluginRegistrar.
48
51
@property (nonatomic , readonly ) NSMutableDictionary * pluginPublications;
@@ -331,6 +334,7 @@ - (void)setViewController:(FlutterViewController*)viewController {
331
334
332
335
- (void )attachView {
333
336
self.iosPlatformView ->attachView ();
337
+ [_textInputPlugin.get () setupIndirectScribbleInteraction: self .viewController];
334
338
}
335
339
336
340
- (void )setFlutterViewControllerWillDeallocObserver : (id <NSObject >)observer {
@@ -355,6 +359,7 @@ - (void)notifyViewControllerDeallocated {
355
359
platform_view->SetOwnerViewController ({});
356
360
}
357
361
}
362
+ [_textInputPlugin.get () resetViewResponder ];
358
363
_viewController.reset ();
359
364
}
360
365
@@ -514,6 +519,8 @@ - (void)setupChannels {
514
519
515
520
_textInputPlugin.reset ([[FlutterTextInputPlugin alloc ] init ]);
516
521
_textInputPlugin.get ().textInputDelegate = self;
522
+ _textInputPlugin.get ().indirectScribbleDelegate = self;
523
+ [_textInputPlugin.get () setupIndirectScribbleInteraction: self .viewController];
517
524
518
525
_platformPlugin.reset ([[FlutterPlatformPlugin alloc ] initWithEngine: [self getWeakPtr ]]);
519
526
@@ -720,22 +727,30 @@ - (void)notifyLowMemory {
720
727
721
728
#pragma mark - Text input delegate
722
729
723
- - (void )updateEditingClient : (int )client withState : (NSDictionary *)state {
730
+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
731
+ updateEditingClient : (int )client
732
+ withState : (NSDictionary *)state {
724
733
[_textInputChannel.get () invokeMethod: @" TextInputClient.updateEditingState"
725
734
arguments: @[ @(client), state ]];
726
735
}
727
736
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 {
729
741
[_textInputChannel.get () invokeMethod: @" TextInputClient.updateEditingStateWithTag"
730
742
arguments: @[ @(client), @{tag : state} ]];
731
743
}
732
744
733
- - (void )updateEditingClient : (int )client withDelta : (NSDictionary *)delta {
745
+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
746
+ updateEditingClient : (int )client
747
+ withDelta : (NSDictionary *)delta {
734
748
[_textInputChannel.get () invokeMethod: @" TextInputClient.updateEditingStateWithDeltas"
735
749
arguments: @[ @(client), delta ]];
736
750
}
737
751
738
- - (void )updateFloatingCursor : (FlutterFloatingCursorDragState)state
752
+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
753
+ updateFloatingCursor : (FlutterFloatingCursorDragState)state
739
754
withClient : (int )client
740
755
withPosition : (NSDictionary *)position {
741
756
NSString * stateString;
@@ -754,7 +769,9 @@ - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
754
769
arguments: @[ @(client), stateString, position ]];
755
770
}
756
771
757
- - (void )performAction : (FlutterTextInputAction)action withClient : (int )client {
772
+ - (void )flutterTextInputView : (FlutterTextInputView*)textInputView
773
+ performAction : (FlutterTextInputAction)action
774
+ withClient : (int )client {
758
775
NSString * actionString;
759
776
switch (action) {
760
777
case FlutterTextInputActionUnspecified:
@@ -799,15 +816,63 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client {
799
816
arguments: @[ @(client), actionString ]];
800
817
}
801
818
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 {
805
823
[_textInputChannel.get () invokeMethod: @" TextInputClient.showAutocorrectionPromptRect"
806
824
arguments: @[ @(client), @(start), @(end) ]];
807
825
}
808
826
809
827
#pragma mark - FlutterViewEngineDelegate
810
828
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
+
811
876
- (flutter::Rasterizer::Screenshot)takeScreenshot : (flutter::Rasterizer::ScreenshotType)type
812
877
asBase64Encoded : (BOOL )base64Encode {
813
878
FML_DCHECK (_shell) << " Cannot takeScreenshot without a shell" ;
0 commit comments