react-native-external-keyboard 0.3.1 → 0.3.2

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.
@@ -20,6 +20,8 @@ using namespace facebook::react;
20
20
 
21
21
  @end
22
22
 
23
+ #endif
24
+
23
25
  static const NSInteger AUTO_FOCUS = 2;
24
26
  static const NSInteger AUTO_BLUR = 2;
25
27
 
@@ -27,56 +29,12 @@ static const NSInteger AUTO_BLUR = 2;
27
29
 
28
30
  }
29
31
 
32
+ #ifdef RCT_NEW_ARCH_ENABLED
30
33
  + (ComponentDescriptorProvider)componentDescriptorProvider
31
34
  {
32
35
  return concreteComponentDescriptorProvider<TextInputFocusWrapperComponentDescriptor>();
33
36
  }
34
37
 
35
- - (BOOL)canBecomeFocused {
36
- return self.canBeFocused;
37
- }
38
-
39
-
40
- - (void)onFocusChange:(BOOL) isFocused {
41
- if (_eventEmitter) {
42
- auto viewEventEmitter = std::static_pointer_cast<TextInputFocusWrapperEventEmitter const>(_eventEmitter);
43
- facebook::react::TextInputFocusWrapperEventEmitter::OnFocusChange data = {
44
- .isFocused = isFocused,
45
- };
46
- viewEventEmitter->onFocusChange(data);
47
- };
48
- }
49
-
50
-
51
- - (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context
52
- withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
53
- BOOL isTextInputFocus = [context.nextFocusedView isKindOfClass: [RCTUITextField class]];
54
- if(isTextInputFocus) {
55
- _textField = (RCTUITextField *)context.nextFocusedView;
56
- if(self.focusType == AUTO_FOCUS) {
57
- [_textField reactFocus];
58
- }
59
- [self onFocusChange: YES];
60
- }
61
-
62
- if(!isTextInputFocus && _textField != nil) {
63
- if(self.blurType == AUTO_BLUR) {
64
- [_textField reactBlur];
65
- }
66
- _textField = nil;
67
- [self onFocusChange: NO];
68
- }
69
- }
70
-
71
-
72
- - (void)willMoveToSuperview:(UIView *)newSuperview {
73
- [super willMoveToSuperview:newSuperview];
74
-
75
- if (newSuperview == nil) {
76
- _textField = nil;
77
- }
78
- }
79
-
80
38
  - (instancetype)initWithFrame:(CGRect)frame
81
39
  {
82
40
  if (self = [super initWithFrame:frame]) {
@@ -87,6 +45,7 @@ static const NSInteger AUTO_BLUR = 2;
87
45
  return self;
88
46
  }
89
47
 
48
+
90
49
  - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
91
50
  {
92
51
  const auto &oldViewProps = *std::static_pointer_cast<TextInputFocusWrapperProps const>(_props);
@@ -118,13 +77,42 @@ Class<RCTComponentViewProtocol> TextInputFocusWrapperCls(void)
118
77
  return RNCEKVTextInputFocusWrapper.class;
119
78
  }
120
79
 
121
- @end
122
80
  #else
123
81
 
124
- static const NSInteger AUTO_FOCUS = 2;
125
- static const NSInteger AUTO_BLUR = 2;
82
+ - (void)didUpdateReactSubviews
83
+ {
84
+ [super didUpdateReactSubviews];
85
+ if (@available(iOS 14.0, *)) {
86
+ self.focusGroupIdentifier = [NSString stringWithFormat:@"app.group.%@", self.reactTag];
87
+ }
88
+ }
89
+
90
+ #endif
91
+
92
+
93
+ #ifdef RCT_NEW_ARCH_ENABLED
94
+
95
+ - (void)onFocusChange:(BOOL) isFocused {
96
+ if (_eventEmitter) {
97
+ auto viewEventEmitter = std::static_pointer_cast<TextInputFocusWrapperEventEmitter const>(_eventEmitter);
98
+ facebook::react::TextInputFocusWrapperEventEmitter::OnFocusChange data = {
99
+ .isFocused = isFocused,
100
+ };
101
+ viewEventEmitter->onFocusChange(data);
102
+ };
103
+ }
104
+
105
+ #else
106
+
107
+
108
+ - (void)onFocusChange:(BOOL) isFocused {
109
+ if(self.onFocusChange) {
110
+ self.onFocusChange(@{ @"isFocused": @(isFocused) });
111
+ }
112
+ }
113
+
114
+ #endif
126
115
 
127
- @implementation RNCEKVTextInputFocusWrapper
128
116
 
129
117
  - (BOOL)canBecomeFocused {
130
118
  return self.canBeFocused;
@@ -133,27 +121,24 @@ static const NSInteger AUTO_BLUR = 2;
133
121
  - (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context
134
122
  withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
135
123
  BOOL isTextInputFocus = [context.nextFocusedView isKindOfClass: [RCTUITextField class]];
136
- if(isTextInputFocus) {
137
- _textField = (RCTUITextField *)context.nextFocusedView;
138
- if(self.focusType == AUTO_FOCUS) {
139
- [_textField reactFocus];
140
- }
141
- if(self.onFocusChange) {
142
- self.onFocusChange(@{ @"isFocused": @(YES) });
143
- }
144
- }
145
-
146
- if(!isTextInputFocus && _textField != nil) {
147
- if(self.blurType == AUTO_BLUR) {
148
- [_textField reactBlur];
149
- }
150
- _textField = nil;
151
- if(self.onFocusChange) {
152
- self.onFocusChange(@{ @"isFocused": @(NO) });
153
- }
124
+ if(isTextInputFocus && (_textField == nil || _textField == context.nextFocusedView)) {
125
+ [self onFocusChange: YES];
126
+ BOOL isTextInputFocus = [context.nextFocusedView isKindOfClass: [RCTUITextField class]];
127
+ if(_textField == nil) {
128
+ _textField = (RCTUITextField *)context.nextFocusedView;
129
+ }
130
+ if(self.focusType == AUTO_FOCUS) {
131
+ [_textField reactFocus];
132
+ }
133
+ } else if (context.previouslyFocusedView == _textField) {
134
+ [self onFocusChange: NO];
135
+ if(self.blurType == AUTO_BLUR) {
136
+ [_textField reactBlur];
137
+ }
154
138
  }
155
139
  }
156
140
 
141
+
157
142
  - (void)willMoveToSuperview:(UIView *)newSuperview {
158
143
  [super willMoveToSuperview:newSuperview];
159
144
 
@@ -162,16 +147,4 @@ static const NSInteger AUTO_BLUR = 2;
162
147
  }
163
148
  }
164
149
 
165
-
166
- - (void)didUpdateReactSubviews
167
- {
168
- [super didUpdateReactSubviews];
169
- if (@available(iOS 14.0, *)) {
170
- self.focusGroupIdentifier = [NSString stringWithFormat:@"app.group.%@", self.reactTag];
171
- }
172
- }
173
-
174
150
  @end
175
-
176
- #endif
177
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-external-keyboard",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",