This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
shell/platform/darwin/ios/framework/Source Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -902,7 +902,14 @@ - (UITextContentType)textContentType {
902902
903903// Prevent UIKit from showing selection handles or highlights. This is needed
904904// because Scribble interactions require the view to have it's actual frame on
905- // the screen.
905+ // the screen. They're not needed on iOS 17 with the new
906+ // UITextSelectionDisplayInteraction API.
907+ //
908+ // These are undocumented methods. On iOS 17, the insertion point color is also
909+ // used as the highlighted background of the selected IME candidate:
910+ // https://github.com/flutter/flutter/issues/132548
911+ // So the respondsToSelector method is overridden to return NO for this method
912+ // on iOS 17+.
906913- (UIColor*)insertionPointColor {
907914 return [UIColor clearColor ];
908915}
@@ -930,6 +937,16 @@ - (UIInputViewController*)inputViewController {
930937 return _textInputPlugin.textInputDelegate ;
931938}
932939
940+ - (BOOL )respondsToSelector : (SEL )selector {
941+ if (@available (iOS 17.0 , *)) {
942+ // See the comment on this method.
943+ if (selector == @selector (insertionPointColor )) {
944+ return NO ;
945+ }
946+ }
947+ return [super respondsToSelector: selector];
948+ }
949+
933950- (void )setTextInputClient : (int )client {
934951 _textInputClient = client;
935952 _hasPlaceholder = NO ;
Original file line number Diff line number Diff line change @@ -786,6 +786,17 @@ - (void)testDisablingAutocorrectDisablesSpellChecking {
786786 XCTAssertEqual (inputView.spellCheckingType , UITextSpellCheckingTypeNo);
787787}
788788
789+ - (void )testFlutterTextInputViewOnlyRespondsToInsertionPointColorBelowIOS17 {
790+ FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] initWithOwner: textInputPlugin];
791+ BOOL respondsToInsertionPointColor =
792+ [inputView respondsToSelector: @selector (insertionPointColor )];
793+ if (@available (iOS 17 , *)) {
794+ XCTAssertFalse (respondsToInsertionPointColor);
795+ } else {
796+ XCTAssertTrue (respondsToInsertionPointColor);
797+ }
798+ }
799+
789800#pragma mark - TextEditingDelta tests
790801- (void )testTextEditingDeltasAreGeneratedOnTextInput {
791802 FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] initWithOwner: textInputPlugin];
You can’t perform that action at this time.
0 commit comments