react-native-external-keyboard 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,12 +37,13 @@ using namespace facebook::react;
|
|
|
37
37
|
RNCEKVFocusDelegate *_focusDelegate;
|
|
38
38
|
RNCEKVGroupIdentifierDelegate *_gIdDelegate;
|
|
39
39
|
RNCEKVFocusOrderDelegate *_focusOrderDelegate;
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
NSNumber *_isFocused;
|
|
42
42
|
BOOL _isAttachedToWindow;
|
|
43
43
|
BOOL _isAttachedToController;
|
|
44
44
|
BOOL _isLinked;
|
|
45
45
|
BOOL _isIdLinked;
|
|
46
|
+
BOOL _autoFocusRequested;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
- (void)link:(UIView *)subview {
|
|
@@ -74,6 +75,8 @@ using namespace facebook::react;
|
|
|
74
75
|
|
|
75
76
|
- (void)onAttached
|
|
76
77
|
{
|
|
78
|
+
[_gIdDelegate updateGroupIdentifier];
|
|
79
|
+
[self focusOnMount];
|
|
77
80
|
if(self.subviews.count > 0) {
|
|
78
81
|
[self link: self.subviews[0]];
|
|
79
82
|
}
|
|
@@ -126,7 +129,7 @@ using namespace facebook::react;
|
|
|
126
129
|
_focusDelegate = [[RNCEKVFocusDelegate alloc] initWithView:self];
|
|
127
130
|
_gIdDelegate = [[RNCEKVGroupIdentifierDelegate alloc] initWithView:self];
|
|
128
131
|
_focusOrderDelegate = [[RNCEKVFocusOrderDelegate alloc] initWithView: self];
|
|
129
|
-
|
|
132
|
+
_autoFocusRequested = NO;
|
|
130
133
|
if (@available(iOS 13.0, *)) {
|
|
131
134
|
UIContextMenuInteraction *interaction =
|
|
132
135
|
[[UIContextMenuInteraction alloc] initWithDelegate:self];
|
|
@@ -162,6 +165,7 @@ using namespace facebook::react;
|
|
|
162
165
|
_customGroupId = nil;
|
|
163
166
|
_enableA11yFocus = NO;
|
|
164
167
|
_isLinked = NO;
|
|
168
|
+
_autoFocusRequested = NO;
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
- (void)setOrderGroup:(NSString *)orderGroup{
|
|
@@ -515,18 +519,8 @@ Class<RCTComponentViewProtocol> ExternalKeyboardViewCls(void) {
|
|
|
515
519
|
[super didMoveToWindow];
|
|
516
520
|
|
|
517
521
|
if (self.window) {
|
|
518
|
-
[_gIdDelegate updateGroupIdentifier];
|
|
519
|
-
[[NSNotificationCenter defaultCenter]
|
|
520
|
-
addObserver:self
|
|
521
|
-
selector:@selector(viewControllerChanged:)
|
|
522
|
-
name:@"ViewControllerChangedNotification"
|
|
523
|
-
object:nil];
|
|
524
522
|
[self onAttached];
|
|
525
523
|
} else {
|
|
526
|
-
[[NSNotificationCenter defaultCenter]
|
|
527
|
-
removeObserver:self
|
|
528
|
-
name:@"ViewControllerChangedNotification"
|
|
529
|
-
object:nil];
|
|
530
524
|
[self onDetached];
|
|
531
525
|
}
|
|
532
526
|
|
|
@@ -577,18 +571,21 @@ Class<RCTComponentViewProtocol> ExternalKeyboardViewCls(void) {
|
|
|
577
571
|
[super willRemoveSubview:subview];
|
|
578
572
|
}
|
|
579
573
|
|
|
580
|
-
- (void)
|
|
574
|
+
- (void)focusOnMount {
|
|
581
575
|
UIViewController *viewController = self.reactViewController;
|
|
582
|
-
UIViewController *shownController = notification.object;
|
|
583
|
-
if(viewController != shownController) return;
|
|
584
576
|
if (self.autoFocus) {
|
|
585
|
-
if(!
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
577
|
+
if(!_autoFocusRequested) {
|
|
578
|
+
_autoFocusRequested = YES;
|
|
579
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
580
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
581
|
+
UIWindow *window = RCTKeyWindow();
|
|
582
|
+
if (window) {
|
|
583
|
+
[self updateFocus:window.rootViewController];
|
|
584
|
+
} else {
|
|
585
|
+
[self updateFocus:viewController];
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
});
|
|
592
589
|
}
|
|
593
590
|
}
|
|
594
591
|
}
|