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 +33
-2
lines changed
shell/platform/darwin/ios/framework/Source Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 21
21
// it is activated.
22
22
static constexpr double kUITextInputAccessibilityEnablingDelaySeconds = 0.5 ;
23
23
24
+ // A delay before reenabling the UIView areAnimationsEnabled to YES
25
+ // in order for becomeFirstResponder to receive the proper value
26
+ static const NSTimeInterval kKeyboardAnimationDelaySeconds = 0.1 ;
27
+
24
28
// The "canonical" invalid CGRect, similar to CGRectNull, used to
25
29
// indicate a CGRect involved in firstRectForRange calculation is
26
30
// invalid. The specific value is chosen so that if firstRectForRange
@@ -2369,8 +2373,13 @@ - (void)dismissKeyboardScreenshot {
2369
2373
- (void )showKeyboardAndRemoveScreenshot {
2370
2374
[UIView setAnimationsEnabled: NO ];
2371
2375
[_cachedFirstResponder becomeFirstResponder ];
2372
- [UIView setAnimationsEnabled: YES ];
2373
- [self dismissKeyboardScreenshot ];
2376
+ // UIKit does not immediately access the areAnimationsEnabled Boolean so a delay is needed before
2377
+ // returned
2378
+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, kKeyboardAnimationDelaySeconds * NSEC_PER_SEC),
2379
+ dispatch_get_main_queue (), ^{
2380
+ [UIView setAnimationsEnabled: YES ];
2381
+ [self dismissKeyboardScreenshot ];
2382
+ });
2374
2383
}
2375
2384
2376
2385
- (void )handlePointerMove : (CGFloat)pointerY {
Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ - (void)cleanUpViewHierarchy:(BOOL)includeActiveView
75
75
- (UIView*)hostView ;
76
76
- (void )addToInputParentViewIfNeeded : (FlutterTextInputView*)inputView ;
77
77
- (void )startLiveTextInput ;
78
+ - (void )showKeyboardAndRemoveScreenshot ;
79
+
78
80
@end
79
81
80
82
@interface FlutterTextInputPluginTest : XCTestCase
@@ -2890,5 +2892,25 @@ - (void)testInteractiveKeyboardKeyboardAnimatesToDismissalPositionalOnPointerUp
2890
2892
}];
2891
2893
textInputPlugin.cachedFirstResponder = nil ;
2892
2894
}
2895
+ - (void )testInteractiveKeyboardShowKeyboardAndRemoveScreenshotAnimationIsNotImmediatelyEnable {
2896
+ [UIView setAnimationsEnabled: YES ];
2897
+ [textInputPlugin showKeyboardAndRemoveScreenshot ];
2898
+ XCTAssertFalse (
2899
+ UIView.areAnimationsEnabled ,
2900
+ @" The animation should still be disabled following showKeyboardAndRemoveScreenshot" );
2901
+ }
2902
+
2903
+ - (void )testInteractiveKeyboardShowKeyboardAndRemoveScreenshotAnimationIsReenabledAfterDelay {
2904
+ [UIView setAnimationsEnabled: YES ];
2905
+ [textInputPlugin showKeyboardAndRemoveScreenshot ];
2906
+
2907
+ NSPredicate * predicate = [NSPredicate predicateWithBlock: ^BOOL (id item, NSDictionary * bindings) {
2908
+ // This will be enabled after a delay
2909
+ return UIView.areAnimationsEnabled ;
2910
+ }];
2911
+ XCTNSPredicateExpectation* expectation =
2912
+ [[XCTNSPredicateExpectation alloc ] initWithPredicate: predicate object: nil ];
2913
+ [self waitForExpectations: @[ expectation ] timeout: 10.0 ];
2914
+ }
2893
2915
2894
2916
@end
You can’t perform that action at this time.
0 commit comments