uilib-native 5.0.0-snapshot.7259 → 5.0.0-snapshot.7298
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.
- package/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +52 -8
- package/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
- package/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
- package/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +70 -15
- package/package.json +1 -1
package/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
#import "LNAnimatorTemp.h"
|
|
15
15
|
|
|
16
|
+
#import "RNNAppDelegate.h"
|
|
17
|
+
|
|
16
18
|
#define kHlperViewTag 0x1f1f1f
|
|
17
19
|
|
|
18
20
|
NSString *const RCTCustomInputControllerKeyboardResigendEventTemp = @"kbdResigned";
|
|
@@ -49,7 +51,6 @@ NSString *const RCTCustomInputControllerKeyboardResigendEventTemp = @"kbdResigne
|
|
|
49
51
|
{
|
|
50
52
|
[self.delegate _WXInputHelperViewResignFirstResponder:self];
|
|
51
53
|
}
|
|
52
|
-
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
return rv;
|
|
@@ -118,17 +119,36 @@ RCT_EXPORT_MODULE(CustomInputControllerTemp)
|
|
|
118
119
|
return [params[@"useSafeArea"] isEqual:@(1)];
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
- (UITextField*)getTextFieldFromTextInputComponentView:(id)inputField {
|
|
123
|
+
UITextField *textField = nil;
|
|
124
|
+
|
|
125
|
+
if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
126
|
+
{
|
|
127
|
+
Ivar textFieldIvar = class_getInstanceVariable([inputField class], "_backedTextInputView");
|
|
128
|
+
if (textFieldIvar != NULL)
|
|
129
|
+
{
|
|
130
|
+
textField = [inputField valueForKey:@"_backedTextInputView"];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return textField;
|
|
135
|
+
}
|
|
136
|
+
|
|
121
137
|
RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag params:(nonnull NSDictionary*)params)
|
|
122
138
|
{
|
|
123
139
|
RCTBridge* bridge = [self.bridge valueForKey:@"parentBridge"];
|
|
124
140
|
if(bridge == nil)
|
|
125
141
|
{
|
|
126
|
-
|
|
142
|
+
bridge = self.bridge;
|
|
127
143
|
}
|
|
128
144
|
|
|
129
145
|
UIView* inputField = [self.bridge.uiManager viewForReactTag:inputFieldTag];
|
|
130
146
|
NSDictionary *initialProps = params[@"initialProps"];
|
|
131
|
-
|
|
147
|
+
|
|
148
|
+
RNNAppDelegate* appDelegate = (RNNAppDelegate*)[UIApplication sharedApplication].delegate;
|
|
149
|
+
UIView *rv = [appDelegate.rootViewFactory viewWithModuleName:params[@"component"]
|
|
150
|
+
initialProperties:initialProps];
|
|
151
|
+
|
|
132
152
|
if(initialProps != nil && initialProps[@"backgroundColor"] != nil)
|
|
133
153
|
{
|
|
134
154
|
UIColor *backgroundColor = [RCTConvert UIColor:initialProps[@"backgroundColor"]];
|
|
@@ -148,7 +168,17 @@ RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag p
|
|
|
148
168
|
helperView.tag = kHlperViewTag;
|
|
149
169
|
helperView.delegate = self;
|
|
150
170
|
|
|
151
|
-
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
174
|
+
{
|
|
175
|
+
UITextField *textField = [self getTextFieldFromTextInputComponentView:inputField];
|
|
176
|
+
if (textField != nil)
|
|
177
|
+
{
|
|
178
|
+
helperView.inputAccessoryView = textField.inputAccessoryView;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if ([inputField isKindOfClass:NSClassFromString(@"RCTTextView")])
|
|
152
182
|
{
|
|
153
183
|
UITextView *textView = nil;
|
|
154
184
|
Ivar backedTextInputIvar = class_getInstanceVariable([inputField class], "_backedTextInput");
|
|
@@ -213,7 +243,17 @@ RCT_EXPORT_METHOD(resetInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
213
243
|
_WXInputHelperViewTemp* helperView = [inputField.superview viewWithTag:kHlperViewTag];
|
|
214
244
|
if(helperView != nil && [helperView isFirstResponder])
|
|
215
245
|
{//restore the first responder only if it was already the first responder to prevent the keyboard from opening again if not necessary
|
|
216
|
-
[inputField
|
|
246
|
+
if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
247
|
+
{
|
|
248
|
+
UITextField *textField = [self getTextFieldFromTextInputComponentView:inputField];
|
|
249
|
+
if (textField != nil)
|
|
250
|
+
{
|
|
251
|
+
[textField reactFocus];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
} else {
|
|
255
|
+
[inputField reactFocus];
|
|
256
|
+
}
|
|
217
257
|
}
|
|
218
258
|
}
|
|
219
259
|
}
|
|
@@ -251,7 +291,7 @@ RCT_EXPORT_METHOD(dismissKeyboard)
|
|
|
251
291
|
}
|
|
252
292
|
}
|
|
253
293
|
|
|
254
|
-
-(UIColor*)reactViewAvgColor:(
|
|
294
|
+
-(UIColor*)reactViewAvgColor:(UIView*)rootView
|
|
255
295
|
{
|
|
256
296
|
if (rootView.frame.size.width == 0 || rootView.frame.size.height == 0)
|
|
257
297
|
{
|
|
@@ -296,7 +336,7 @@ RCT_EXPORT_METHOD(expandFullScreenForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
296
336
|
helperView.keepInSuperviewOnResign = YES;
|
|
297
337
|
|
|
298
338
|
RCTCustomKeyboardViewControllerTemp *customKeyboardViewController = (RCTCustomKeyboardViewControllerTemp*)helperView.inputViewController;
|
|
299
|
-
|
|
339
|
+
UIView *rv = customKeyboardViewController.rootView;
|
|
300
340
|
UIInputView *inputView = helperView.inputViewController.inputView;
|
|
301
341
|
|
|
302
342
|
_fullScreenWindow = [[UIWindow alloc] initWithFrame:[inputView.window convertRect:inputView.bounds fromView:inputView]];
|
|
@@ -370,7 +410,7 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
370
410
|
completionHandler:^(BOOL completed)
|
|
371
411
|
{
|
|
372
412
|
RCTCustomKeyboardViewControllerTemp *customKeyboardViewController = (RCTCustomKeyboardViewControllerTemp*)helperView.inputViewController;
|
|
373
|
-
|
|
413
|
+
UIView *rv = _fullScreenWindow.rootViewController.view;
|
|
374
414
|
|
|
375
415
|
[UIView performWithoutAnimation:^{
|
|
376
416
|
|
|
@@ -388,6 +428,8 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
388
428
|
}
|
|
389
429
|
}
|
|
390
430
|
|
|
431
|
+
|
|
432
|
+
|
|
391
433
|
#pragma mark - _WXInputHelperViewDelegateTemp methods
|
|
392
434
|
|
|
393
435
|
-(void)_WXInputHelperViewResignFirstResponder:(UIView*)wxInputHelperView
|
|
@@ -397,6 +439,8 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
397
439
|
[self sendEventWithName:RCTCustomInputControllerKeyboardResigendEventTemp body:nil];
|
|
398
440
|
}
|
|
399
441
|
self.customInputComponentPresented = NO;
|
|
442
|
+
|
|
443
|
+
|
|
400
444
|
}
|
|
401
445
|
|
|
402
446
|
@end
|
|
@@ -7,18 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
#import <UIKit/UIKit.h>
|
|
9
9
|
|
|
10
|
-
#if __has_include(<React/RCTRootView.h>)
|
|
11
|
-
#import <React/RCTRootView.h>
|
|
12
|
-
#else
|
|
13
|
-
#import "RCTRootView.h"
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
10
|
@interface RCTCustomKeyboardViewControllerTemp : UIInputViewController
|
|
17
11
|
|
|
18
12
|
- (void) setAllowsSelfSizing:(BOOL)allowsSelfSizing;
|
|
19
13
|
- (instancetype)initWithUsingSafeArea:(BOOL)useSafeArea;
|
|
20
14
|
|
|
21
15
|
@property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
|
|
22
|
-
@property (nonatomic, strong)
|
|
16
|
+
@property (nonatomic, strong) UIView *rootView;
|
|
23
17
|
|
|
24
18
|
@end
|
|
@@ -193,28 +193,28 @@ typedef NS_ENUM(NSUInteger, KeyboardTrackingScrollBehavior) {
|
|
|
193
193
|
if(_scrollViewToManage == nil)
|
|
194
194
|
{
|
|
195
195
|
if ([NSStringFromClass([subview class]) isEqualToString:@"RCTScrollViewComponentView"]) {
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
UIScrollView *scrollView = [self extractUIScrollView:subview];
|
|
197
|
+
|
|
198
198
|
if ([scrollView isKindOfClass:[UIScrollView class]])
|
|
199
199
|
{
|
|
200
200
|
if(_requiresSameParentToManageScrollView && subview.superview == self.superview)
|
|
201
201
|
{
|
|
202
|
-
|
|
202
|
+
_scrollViewToManage = scrollView;
|
|
203
203
|
}
|
|
204
204
|
else if(!_requiresSameParentToManageScrollView)
|
|
205
205
|
{
|
|
206
|
-
|
|
206
|
+
_scrollViewToManage = scrollView;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
if(_scrollViewToManage != nil)
|
|
210
210
|
{
|
|
211
|
-
|
|
211
|
+
_scrollIsInverted = CGAffineTransformEqualToTransform(subview.superview.transform, CGAffineTransformMakeScale(1, -1));
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
|
|
219
219
|
if ([subview isKindOfClass:NSClassFromString(@"RCTTextField")])
|
|
220
220
|
{
|
|
@@ -238,17 +238,30 @@ typedef NS_ENUM(NSUInteger, KeyboardTrackingScrollBehavior) {
|
|
|
238
238
|
{
|
|
239
239
|
[self setupTextView:[subview valueForKey:@"_backedTextInputView"]];
|
|
240
240
|
}
|
|
241
|
-
else if ([subview isKindOfClass:NSClassFromString(@"RCTTextView")]
|
|
241
|
+
else if ([subview isKindOfClass:NSClassFromString(@"RCTTextView")] ||
|
|
242
|
+
[subview isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
242
243
|
{
|
|
244
|
+
|
|
243
245
|
UITextView *textView = nil;
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
|
|
247
|
+
if ([subview isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")]) {
|
|
248
|
+
Ivar textFieldIvar = class_getInstanceVariable([subview class], "_backedTextInputView");
|
|
249
|
+
if (textFieldIvar != NULL)
|
|
250
|
+
{
|
|
251
|
+
textView = [subview valueForKey:@"_backedTextInputView"];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
} else {
|
|
255
|
+
|
|
256
|
+
Ivar backedTextInputIvar = class_getInstanceVariable([subview class], "_backedTextInput");
|
|
257
|
+
if (backedTextInputIvar != NULL)
|
|
258
|
+
{
|
|
259
|
+
textView = [subview valueForKey:@"_backedTextInput"];
|
|
260
|
+
}
|
|
261
|
+
else if([subview isKindOfClass:[UITextView class]])
|
|
262
|
+
{
|
|
263
|
+
textView = (UITextView*)subview;
|
|
264
|
+
}
|
|
252
265
|
}
|
|
253
266
|
[self setupTextView:textView];
|
|
254
267
|
}
|
|
@@ -283,6 +296,8 @@ typedef NS_ENUM(NSUInteger, KeyboardTrackingScrollBehavior) {
|
|
|
283
296
|
_originalHeight = _ObservingInputAccessoryViewTemp.height;
|
|
284
297
|
|
|
285
298
|
[self addBottomViewIfNecessary];
|
|
299
|
+
|
|
300
|
+
[self ensureLegacyViewManagerTouchDelegation];
|
|
286
301
|
}
|
|
287
302
|
|
|
288
303
|
- (void)setupTextView:(UITextView*)textView
|
|
@@ -564,9 +579,48 @@ typedef NS_ENUM(NSUInteger, KeyboardTrackingScrollBehavior) {
|
|
|
564
579
|
[self updateBottomViewFrame];
|
|
565
580
|
|
|
566
581
|
self.transform = CGAffineTransformMakeTranslation(0, accessoryTranslation);
|
|
582
|
+
|
|
567
583
|
[self _updateScrollViewInsets];
|
|
568
584
|
}
|
|
569
585
|
|
|
586
|
+
- (void)ensureLegacyViewManagerTouchDelegation {
|
|
587
|
+
UIView *superview = self.superview;
|
|
588
|
+
if (superview) {
|
|
589
|
+
if ([NSStringFromClass([superview class]) isEqualToString:@"RCTLegacyViewManagerInteropComponentView"]) {
|
|
590
|
+
[self changeLegacyViewManagerHitTestDelegation:superview];
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
- (void)changeLegacyViewManagerHitTestDelegation:(UIView *)wrapperView {
|
|
596
|
+
static dispatch_once_t onceToken;
|
|
597
|
+
static IMP originalHitTestIMP = NULL;
|
|
598
|
+
|
|
599
|
+
dispatch_once(&onceToken, ^{
|
|
600
|
+
Class wrapperClass = [wrapperView class];
|
|
601
|
+
|
|
602
|
+
Method originalMethod = class_getInstanceMethod(wrapperClass, @selector(hitTest:withEvent:));
|
|
603
|
+
if (originalMethod) {
|
|
604
|
+
originalHitTestIMP = method_getImplementation(originalMethod);
|
|
605
|
+
|
|
606
|
+
IMP customHitTest = imp_implementationWithBlock(^UIView*(id self, CGPoint point, UIEvent *event) {
|
|
607
|
+
UIView *subview = [self subviews].firstObject;
|
|
608
|
+
if (subview &&
|
|
609
|
+
[subview isKindOfClass:[KeyboardTrackingViewTemp class]]) {
|
|
610
|
+
CGPoint convertedPoint = [self convertPoint:point toView:subview];
|
|
611
|
+
UIView *result = [subview hitTest:convertedPoint withEvent:event];
|
|
612
|
+
return result;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
UIView* (*originalFunc)(id, SEL, CGPoint, UIEvent*) = (void*)originalHitTestIMP;
|
|
616
|
+
return originalFunc(self, @selector(hitTest:withEvent:), point, event);
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
method_setImplementation(originalMethod, customHitTest);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
|
|
570
624
|
- (void)performScrollToFocusedInput
|
|
571
625
|
{
|
|
572
626
|
if (_scrollViewToManage != nil && self.scrollToFocusedInput)
|
|
@@ -748,3 +802,4 @@ RCT_EXPORT_METHOD(scrollToStart:(nonnull NSNumber *)reactTag)
|
|
|
748
802
|
}
|
|
749
803
|
|
|
750
804
|
@end
|
|
805
|
+
|
package/package.json
CHANGED