From de2ccc20e30bdd73d6a5d3ea852faa9439817221 Mon Sep 17 00:00:00 2001 From: luckysmg <2539699336@qq.com> Date: Thu, 30 Mar 2023 16:11:57 +0800 Subject: [PATCH] Revert "[iOS] Send connectionClosed message when resignFirstResponder to ensure framework focus state is correct. (#40703)" (flutter/engine#40777) Revert "[iOS] Send connectionClosed message when resignFirstResponder to ensure framework focus state is correct." --- .../ios/framework/Source/FlutterEngine.mm | 9 +-------- .../ios/framework/Source/FlutterEngineTest.mm | 18 ------------------ .../Source/FlutterTextInputDelegate.h | 4 ++-- .../framework/Source/FlutterTextInputPlugin.mm | 3 +-- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 422a6155e4..ff94acaa27 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -1095,14 +1095,7 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS arguments:@[ @(client) ]]; } -- (void)flutterTextInputView:(FlutterTextInputView*)textInputView - didResignFirstResponderWithTextInputClient:(int)client { - // When flutter text input view resign first responder, send a message to - // framework to ensure the focus state is correct. This is useful when close - // keyboard from platform side. - [_textInputChannel.get() invokeMethod:@"TextInputClient.onConnectionClosed" - arguments:@[ @(client) ]]; - +- (void)flutterTextInputViewDidResignFirstResponder:(FlutterTextInputView*)textInputView { // Platform view's first responder detection logic: // // All text input widgets (e.g. EditableText) are backed by a dummy UITextInput view diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index b4dfb9502f..7bd90a6a5a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -13,14 +13,9 @@ #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/FlutterEngine_Test.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" FLUTTER_ASSERT_ARC -@interface FlutterEngine () - -@end - @interface FlutterEngineTest : XCTestCase @end @@ -318,17 +313,4 @@ FLUTTER_ASSERT_ARC } } -- (void)testFlutterTextInputViewDidResignFirstResponderWillCallTextInputClientConnectionClosed { - id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]); - FlutterEngine* engine = [[FlutterEngine alloc] init]; - [engine setBinaryMessenger:mockBinaryMessenger]; - [engine runWithEntrypoint:FlutterDefaultDartEntrypoint initialRoute:@"test"]; - [engine flutterTextInputView:nil didResignFirstResponderWithTextInputClient:1]; - FlutterMethodCall* methodCall = - [FlutterMethodCall methodCallWithMethodName:@"TextInputClient.onConnectionClosed" - arguments:@[ @(1) ]]; - NSData* encodedMethodCall = [[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:methodCall]; - OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/textinput" message:encodedMethodCall]); -} - @end diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index cea4dd88da..7ecda6a23b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -59,8 +59,8 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { insertTextPlaceholderWithSize:(CGSize)size withClient:(int)client; - (void)flutterTextInputView:(FlutterTextInputView*)textInputView removeTextPlaceholder:(int)client; -- (void)flutterTextInputView:(FlutterTextInputView*)textInputView - didResignFirstResponderWithTextInputClient:(int)client; +- (void)flutterTextInputViewDidResignFirstResponder:(FlutterTextInputView*)textInputView; + @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_ diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 19aebe126a..1ac316e819 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -1043,8 +1043,7 @@ static BOOL IsSelectionRectCloserToPoint(CGPoint point, - (BOOL)resignFirstResponder { BOOL success = [super resignFirstResponder]; if (success) { - [self.textInputDelegate flutterTextInputView:self - didResignFirstResponderWithTextInputClient:_textInputClient]; + [self.textInputDelegate flutterTextInputViewDidResignFirstResponder:self]; } return success; }