Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Support Scribble Handwriting #24224

Merged
merged 63 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8278027
[scribble+master] [scribble] Very rough proof of concept
fbcouch Dec 16, 2020
9104fe5
[scribble+master] Addressing PR feedback: remove scribbleInProgress f…
fbcouch Feb 9, 2021
abbdbf9
[scribble+master] Improve closestPositionToPoint algorithm
fbcouch Feb 24, 2021
92268b9
[scribble+master] Add tests, refactor the closestPositionToPoint meth…
fbcouch Feb 25, 2021
2af5fe9
[scribble+master] Run clang-format
fbcouch Feb 26, 2021
0844910
[scribble+master] Pass calls to insertTextPlaceholderWithSize and rem…
fbcouch Mar 5, 2021
3e87027
[scribble+master] Update scribble support to handle multi-byte charac…
fbcouch Apr 6, 2021
d230e1b
[scribble+master-updated] Clean up some misses during rebasing, remov…
fbcouch Apr 8, 2021
6035793
[scribble+master-updated] Fixup my tests
fbcouch Apr 8, 2021
9105c21
[scribble+master] Clear selection rects on insert text with placehold…
fbcouch Apr 21, 2021
487bab4
[scribble+master] Add placeholder selection rects when inserting text…
fbcouch Apr 30, 2021
7c784c3
[scribble+master] Add back autofill hider stuff, which seems to work …
fbcouch Apr 30, 2021
b57c05a
[scribble+master] Add Twin Sun, LLC to AUTHORS
fbcouch Apr 30, 2021
ed6d050
[scribble+master] Remove NSLogs and some TODOs
fbcouch May 6, 2021
5746e60
[scribble+master] Add 'resetViewController' method to FlutterTextInpu…
fbcouch May 20, 2021
97c67b4
[scribble+master] Pass FlutterViewController into setupIndirectScribb…
fbcouch May 21, 2021
deb3ae9
[scribble+master] Address PR feedback – memory management, extract co…
fbcouch Jun 4, 2021
9d2e501
[scribble+master] Remove FlutterViewController import, remove unneces…
fbcouch Jul 1, 2021
67d471a
[scribble+master] Use dynamic instead of synthesize for inherited pro…
fbcouch Jul 1, 2021
d10c767
[scribble+master] Remove some useless copy calls, extract logic of fi…
fbcouch Jul 1, 2021
561935f
[scribble+master] Adding some (I think) missing autoreleases and clea…
fbcouch Jul 1, 2021
4be3dd2
[scribble+master] Remove a couple more unnecessary synthesize calls, …
fbcouch Jul 1, 2021
25f4100
[scribble+master] Swap back to synthesize for FlutterTextSelectionRec…
fbcouch Jul 1, 2021
34db3dd
[scribble+master] Genericize selectionRects NSArray
fbcouch Jul 1, 2021
f6adcd9
[scribble+master] Merge branch 'master' into feature/scribble+master
fbcouch Jul 1, 2021
82f9ce6
[scribble+master] Fix formatting issues and swap from _reusableInputV…
fbcouch Jul 1, 2021
85f8665
Couple more memory things
fbcouch Jul 1, 2021
ea37dfa
Clear scribbleFocused flag in touchesBegan, insert/delete text rather…
fbcouch Jul 2, 2021
671f29c
did a bit of cleanup (the easy stuff)
gaaclarke Jul 3, 2021
6eed8a7
extract FlutterIndirectScribbleDelegate interface to handle requestEl…
fbcouch Jul 13, 2021
39a3579
Merge branch 'master' into feature/scribble+master
fbcouch Jul 20, 2021
6ac1cb6
Update new member of FlutterTextInputDelegate to pass caller as first…
fbcouch Jul 20, 2021
b123246
Refactor out FlutterViewResponder protocol, swap focused/focusing boo…
fbcouch Jul 20, 2021
46bacea
Add position member to FlutterTextSelectionRect and use that to repre…
fbcouch Jul 20, 2021
a622e83
Fix linter errors
fbcouch Jul 20, 2021
640267e
Fix tests to use new selection rects and delegate style
fbcouch Jul 22, 2021
f2d67b5
Add some more tests for scribble functions
fbcouch Jul 26, 2021
7bfe2e9
Add new headers to licenses_flutter golden file
fbcouch Jul 26, 2021
8fae879
Rename viewController to viewResponder; move viewResponder prop on th…
fbcouch Jul 26, 2021
4008ea4
More PR changes; provide frame to inputHider so that UIScribbleIntera…
fbcouch Aug 4, 2021
c6aa05e
Swap scribbleInProgress over to enum, fix issue where cursor wouldn't…
fbcouch Aug 4, 2021
a39f759
Fix up tests, remove logs, prevent native toolbar from popping up
fbcouch Aug 4, 2021
7a4e440
Add back errant removal of setSelectedTextRangeLocal call in replaceR…
fbcouch Aug 7, 2021
3ec718b
Merge branch 'master' into feature/scribble+master
fbcouch Aug 9, 2021
a95f2d9
Add workarounds for UITextInteraction-related selection and gesture p…
fbcouch Aug 9, 2021
c0aeba0
Change up workaround a bit to move add the UITextInteraction in -begi…
fbcouch Aug 11, 2021
ae8f536
Move setup of UIScribbleInteraction to the init method of FlutterText…
fbcouch Aug 11, 2021
f106b91
Remove remaining NSLog
fbcouch Aug 12, 2021
a141a14
Add guard clause to selectionRectsForRange to prevent crash when chan…
fbcouch Aug 12, 2021
2303259
Merge branch 'master' into feature/scribble+master
fbcouch Aug 30, 2021
fc8c9b1
Clean up some comments
fbcouch Sep 16, 2021
a9e02ae
Merge branch 'master' into feature/scribble+master
fbcouch Sep 16, 2021
3966913
Add comment explaining isCloserVertically
fbcouch Sep 24, 2021
7d75e7e
Merge branch 'master' into feature/scribble+master
fbcouch Sep 24, 2021
cbfd5b3
Fix compile error (need to add flutterTextInputView art to - updateEd…
fbcouch Sep 26, 2021
8ea77a7
Update - updateEditingClient:withDelta: in tests
fbcouch Sep 27, 2021
4ee848f
Merge branch 'master' into feature/scribble+master
fbcouch Oct 6, 2021
2dd299f
Merge branch 'master' into feature/scribble+master
fbcouch Oct 18, 2021
75e9b06
Merge branch 'feature/scribble+master' of github.com:twinsunllc/engin…
fbcouch Oct 18, 2021
99de581
Merge branch 'master' into feature/scribble+master
fbcouch Oct 26, 2021
07e195c
Incorporate feedback
fbcouch Nov 5, 2021
975177b
Merge branch 'master' into feature/scribble+master
fbcouch Nov 5, 2021
ee11699
Rename scribbleInteraction variable
fbcouch Nov 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ Hidenori Matsubayashi <[email protected]>
Sarbagya Dhaubanjar <[email protected]>
Callum Moffat <[email protected]>
Koutaro Mori <[email protected]>
TheOneWithTheBraid <[email protected]>
TheOneWithTheBraid <[email protected]>
Twin Sun, LLC <[email protected]>
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterHeadlessDartRunner.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyPrimaryResponder.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySecondaryResponder.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h
Expand Down Expand Up @@ -1133,6 +1134,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/IOKit.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap.mm
Expand Down
83 changes: 74 additions & 9 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "flutter/shell/platform/darwin/common/command_line.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
Expand All @@ -42,7 +43,9 @@ @interface FlutterEngineRegistrar : NSObject <FlutterPluginRegistrar>
- (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine*)flutterEngine;
@end

@interface FlutterEngine () <FlutterTextInputDelegate, FlutterBinaryMessenger>
@interface FlutterEngine () <FlutterIndirectScribbleDelegate,
FlutterTextInputDelegate,
FlutterBinaryMessenger>
// Maintains a dictionary of plugin names that have registered with the engine. Used by
// FlutterEngineRegistrar to implement a FlutterPluginRegistrar.
@property(nonatomic, readonly) NSMutableDictionary* pluginPublications;
Expand Down Expand Up @@ -331,6 +334,7 @@ - (void)setViewController:(FlutterViewController*)viewController {

- (void)attachView {
self.iosPlatformView->attachView();
[_textInputPlugin.get() setupIndirectScribbleInteraction:self.viewController];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Came across this while looking into refactoring attachView. Does it make sense to move this line somewhere else? setupIndirectScribbleInteraction:self doesn't sound like should be a part of "attachView"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's a better place for it...iirc it's purpose here is to make sure the indirect scribble interaction is set up along with the view – that is something that needs to always be there so that we can capture scribble interactions that happen outside of text areas

}

- (void)setFlutterViewControllerWillDeallocObserver:(id<NSObject>)observer {
Expand All @@ -355,6 +359,7 @@ - (void)notifyViewControllerDeallocated {
platform_view->SetOwnerViewController({});
}
}
[_textInputPlugin.get() resetViewResponder];
_viewController.reset();
}

Expand Down Expand Up @@ -514,6 +519,8 @@ - (void)setupChannels {

_textInputPlugin.reset([[FlutterTextInputPlugin alloc] init]);
_textInputPlugin.get().textInputDelegate = self;
_textInputPlugin.get().indirectScribbleDelegate = self;
[_textInputPlugin.get() setupIndirectScribbleInteraction:self.viewController];

_platformPlugin.reset([[FlutterPlatformPlugin alloc] initWithEngine:[self getWeakPtr]]);

Expand Down Expand Up @@ -720,22 +727,30 @@ - (void)notifyLowMemory {

#pragma mark - Text input delegate

- (void)updateEditingClient:(int)client withState:(NSDictionary*)state {
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateEditingClient:(int)client
withState:(NSDictionary*)state {
[_textInputChannel.get() invokeMethod:@"TextInputClient.updateEditingState"
arguments:@[ @(client), state ]];
}

- (void)updateEditingClient:(int)client withState:(NSDictionary*)state withTag:(NSString*)tag {
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateEditingClient:(int)client
withState:(NSDictionary*)state
withTag:(NSString*)tag {
[_textInputChannel.get() invokeMethod:@"TextInputClient.updateEditingStateWithTag"
arguments:@[ @(client), @{tag : state} ]];
}

- (void)updateEditingClient:(int)client withDelta:(NSDictionary*)delta {
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateEditingClient:(int)client
withDelta:(NSDictionary*)delta {
[_textInputChannel.get() invokeMethod:@"TextInputClient.updateEditingStateWithDeltas"
arguments:@[ @(client), delta ]];
}

- (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateFloatingCursor:(FlutterFloatingCursorDragState)state
withClient:(int)client
withPosition:(NSDictionary*)position {
NSString* stateString;
Expand All @@ -754,7 +769,9 @@ - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
arguments:@[ @(client), stateString, position ]];
}

- (void)performAction:(FlutterTextInputAction)action withClient:(int)client {
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
performAction:(FlutterTextInputAction)action
withClient:(int)client {
NSString* actionString;
switch (action) {
case FlutterTextInputActionUnspecified:
Expand Down Expand Up @@ -799,15 +816,63 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client {
arguments:@[ @(client), actionString ]];
}

- (void)showAutocorrectionPromptRectForStart:(NSUInteger)start
end:(NSUInteger)end
withClient:(int)client {
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
showAutocorrectionPromptRectForStart:(NSUInteger)start
end:(NSUInteger)end
withClient:(int)client {
[_textInputChannel.get() invokeMethod:@"TextInputClient.showAutocorrectionPromptRect"
arguments:@[ @(client), @(start), @(end) ]];
}

#pragma mark - FlutterViewEngineDelegate

- (void)flutterTextInputView:(FlutterTextInputView*)textInputView showToolbar:(int)client {
[_textInputChannel.get() invokeMethod:@"TextInputClient.showToolbar" arguments:@[ @(client) ]];
}

- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
focusElement:(UIScribbleElementIdentifier)elementIdentifier
atPoint:(CGPoint)referencePoint
result:(FlutterResult)callback {
[_textInputChannel.get()
invokeMethod:@"TextInputClient.focusElement"
arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ]
result:callback];
}

- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
requestElementsInRect:(CGRect)rect
result:(FlutterResult)callback {
[_textInputChannel.get()
invokeMethod:@"TextInputClient.requestElementsInRect"
arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ]
result:callback];
}

- (void)flutterTextInputViewScribbleInteractionBegan:(FlutterTextInputView*)textInputView {
[_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionBegan" arguments:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a framework pr associated with the change? it may be easier to review if you can also create the framework part pr

Copy link
Contributor Author

@fbcouch fbcouch May 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chunhtai Yes, I should have put a link to it in the description. Here it is: flutter/flutter#75472

}

- (void)flutterTextInputViewScribbleInteractionFinished:(FlutterTextInputView*)textInputView {
[_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionFinished"
arguments:nil];
}

- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
insertTextPlaceholderWithSize:(CGSize)size
withClient:(int)client {
[_textInputChannel.get() invokeMethod:@"TextInputClient.insertTextPlaceholder"
arguments:@[ @(client), @(size.width), @(size.height) ]];
}

- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
removeTextPlaceholder:(int)client {
[_textInputChannel.get() invokeMethod:@"TextInputClient.removeTextPlaceholder"
arguments:@[ @(client) ]];
}

#pragma mark - Screenshot Delegate

- (flutter::Rasterizer::Screenshot)takeScreenshot:(flutter::Rasterizer::ScreenshotType)type
asBase64Encoded:(BOOL)base64Encode {
FML_DCHECK(_shell) << "Cannot takeScreenshot without a shell";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERINDIRECTSCRIBBLEDELEGATE_H_
#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERINDIRECTSCRIBBLEDELEGATE_H_

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@class FlutterTextInputPlugin;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have NS_ASSUME_NONNULL_BEGIN and NS_ASSUME_NONNULL_END.

@protocol FlutterIndirectScribbleDelegate <NSObject>
- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
focusElement:(UIScribbleElementIdentifier)elementIdentifier
atPoint:(CGPoint)referencePoint
result:(FlutterResult)callback;
- (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin
requestElementsInRect:(CGRect)rect
result:(FlutterResult)callback;
@end
NS_ASSUME_NONNULL_END

#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERINDIRECTSCRIBBLEDELEGATE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#import <Foundation/Foundation.h>

@class FlutterTextInputPlugin;
@class FlutterTextInputView;

typedef NS_ENUM(NSInteger, FlutterTextInputAction) {
FlutterTextInputActionUnspecified,
FlutterTextInputActionDone,
Expand All @@ -28,16 +31,35 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) {
};

@protocol FlutterTextInputDelegate <NSObject>
- (void)updateEditingClient:(int)client withState:(NSDictionary*)state;
- (void)updateEditingClient:(int)client withState:(NSDictionary*)state withTag:(NSString*)tag;
- (void)updateEditingClient:(int)client withDelta:(NSDictionary*)state;
- (void)performAction:(FlutterTextInputAction)action withClient:(int)client;
- (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateEditingClient:(int)client
withState:(NSDictionary*)state;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateEditingClient:(int)client
withState:(NSDictionary*)state
withTag:(NSString*)tag;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateEditingClient:(int)client
withDelta:(NSDictionary*)state;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
performAction:(FlutterTextInputAction)action
withClient:(int)client;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
updateFloatingCursor:(FlutterFloatingCursorDragState)state
withClient:(int)client
withPosition:(NSDictionary*)point;
- (void)showAutocorrectionPromptRectForStart:(NSUInteger)start
end:(NSUInteger)end
withClient:(int)client;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
showAutocorrectionPromptRectForStart:(NSUInteger)start
end:(NSUInteger)end
withClient:(int)client;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView showToolbar:(int)client;
- (void)flutterTextInputViewScribbleInteractionBegan:(FlutterTextInputView*)textInputView;
- (void)flutterTextInputViewScribbleInteractionFinished:(FlutterTextInputView*)textInputView;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
insertTextPlaceholderWithSize:(CGSize)size
withClient:(int)client;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView removeTextPlaceholder:(int)client;

@end

#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,32 @@
#import <UIKit/UIKit.h>

#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySecondaryResponder.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextEditingDelta.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h"

@interface FlutterTextInputPlugin : NSObject <FlutterKeySecondaryResponder>
typedef NS_ENUM(NSInteger, FlutterScribbleFocusStatus) {
FlutterScribbleFocusStatusUnfocused,
FlutterScribbleFocusStatusFocusing,
FlutterScribbleFocusStatusFocused,
};

typedef NS_ENUM(NSInteger, FlutterScribbleInteractionStatus) {
FlutterScribbleInteractionStatusNone,
FlutterScribbleInteractionStatusStarted,
FlutterScribbleInteractionStatusEnding,
};

@interface FlutterTextInputPlugin
: NSObject <FlutterKeySecondaryResponder, UIIndirectScribbleInteractionDelegate>

@property(nonatomic, assign) id<FlutterTextInputDelegate> textInputDelegate;
@property(nonatomic, assign) UIViewController* viewController;
@property(nonatomic, assign) id<FlutterIndirectScribbleDelegate> indirectScribbleDelegate;
@property(nonatomic, strong)
NSMutableDictionary<UIScribbleElementIdentifier, NSValue*>* scribbleElements;
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;

/**
Expand All @@ -26,6 +44,13 @@
*/
- (UIView<UITextInput>*)textInputView;

/**
* These are used by the UIIndirectScribbleInteractionDelegate methods to handle focusing on the
* correct element.
*/
- (void)setupIndirectScribbleInteraction:(id<FlutterViewResponder>)viewResponder;
- (void)resetViewResponder;

@end

/** An indexed position in the buffer of a Flutter text editing widget. */
Expand All @@ -51,10 +76,41 @@
@interface FlutterTokenizer : UITextInputStringTokenizer
@end

@interface FlutterTextSelectionRect : UITextSelectionRect

@property(nonatomic, assign) CGRect rect;
@property(nonatomic) NSUInteger position;
@property(nonatomic, assign) NSWritingDirection writingDirection;
@property(nonatomic) BOOL containsStart;
@property(nonatomic) BOOL containsEnd;
@property(nonatomic) BOOL isVertical;

+ (instancetype)selectionRectWithRectAndInfo:(CGRect)rect
position:(NSUInteger)position
writingDirection:(NSWritingDirection)writingDirection
containsStart:(BOOL)containsStart
containsEnd:(BOOL)containsEnd
isVertical:(BOOL)isVertical;

+ (instancetype)selectionRectWithRect:(CGRect)rect position:(NSUInteger)position;

- (instancetype)initWithRectAndInfo:(CGRect)rect
position:(NSUInteger)position
writingDirection:(NSWritingDirection)writingDirection
containsStart:(BOOL)containsStart
containsEnd:(BOOL)containsEnd
isVertical:(BOOL)isVertical;

- (instancetype)init NS_UNAVAILABLE;
@end

API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder : UITextPlaceholder
@end

#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
FLUTTER_DARWIN_EXPORT
#endif
@interface FlutterTextInputView : UIView <UITextInput>
@interface FlutterTextInputView : UIView <UITextInput, UIScribbleInteractionDelegate>

// UITextInput
@property(nonatomic, readonly) NSMutableString* text;
Expand All @@ -81,5 +137,11 @@ FLUTTER_DARWIN_EXPORT
@property(nonatomic, assign) id<FlutterTextInputDelegate> textInputDelegate;
@property(nonatomic, assign) UIAccessibilityElement* backingTextInputAccessibilityObject;

// Scribble Support
@property(nonatomic, assign) id<FlutterViewResponder> viewResponder;
@property(nonatomic) FlutterScribbleFocusStatus scribbleFocusStatus;
@property(nonatomic, strong) NSArray<FlutterTextSelectionRect*>* selectionRects;
- (void)resetScribbleInteractionStatusIfEnding;

@end
#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_
Loading