|
| 1 | +/** |
| 2 | + * Copyright (c) 2015-present, Facebook, Inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * This source code is licensed under the BSD-style license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 7 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 8 | + */ |
| 9 | + |
| 10 | +#import "RCTBaseTextInputViewManager.h" |
| 11 | + |
| 12 | +#import <React/RCTBridge.h> |
| 13 | +#import <React/RCTConvert.h> |
| 14 | +#import <React/RCTFont.h> |
| 15 | +#import <React/RCTShadowView+Layout.h> |
| 16 | +#import <React/RCTShadowView.h> |
| 17 | + |
| 18 | +#import "RCTConvert+Text.h" |
| 19 | +#import "RCTBaseTextInputView.h" |
| 20 | + |
| 21 | +@implementation RCTBaseTextInputViewManager |
| 22 | + |
| 23 | +RCT_EXPORT_MODULE() |
| 24 | + |
| 25 | +#pragma mark - Unified <TextInput> properties |
| 26 | + |
| 27 | +RCT_REMAP_VIEW_PROPERTY(allowFontScaling, fontAttributes.allowFontScaling, BOOL) |
| 28 | +RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType) |
| 29 | +RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType) |
| 30 | +RCT_REMAP_VIEW_PROPERTY(color, backedTextInputView.textColor, UIColor) |
| 31 | +RCT_REMAP_VIEW_PROPERTY(editable, backedTextInputView.editable, BOOL) |
| 32 | +RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, backedTextInputView.enablesReturnKeyAutomatically, BOOL) |
| 33 | +RCT_REMAP_VIEW_PROPERTY(fontSize, fontAttributes.fontSize, NSNumber) |
| 34 | +RCT_REMAP_VIEW_PROPERTY(fontWeight, fontAttributes.fontWeight, NSString) |
| 35 | +RCT_REMAP_VIEW_PROPERTY(fontStyle, fontAttributes.fontStyle, NSString) |
| 36 | +RCT_REMAP_VIEW_PROPERTY(fontFamily, fontAttributes.fontFamily, NSString) |
| 37 | +RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, backedTextInputView.keyboardAppearance, UIKeyboardAppearance) |
| 38 | +RCT_REMAP_VIEW_PROPERTY(keyboardType, backedTextInputView.keyboardType, UIKeyboardType) |
| 39 | +RCT_REMAP_VIEW_PROPERTY(placeholder, backedTextInputView.placeholder, NSString) |
| 40 | +RCT_REMAP_VIEW_PROPERTY(placeholderTextColor, backedTextInputView.placeholderColor, UIColor) |
| 41 | +RCT_REMAP_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) |
| 42 | +RCT_REMAP_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) |
| 43 | +RCT_REMAP_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) |
| 44 | +RCT_REMAP_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) |
| 45 | +RCT_REMAP_VIEW_PROPERTY(textAlign, backedTextInputView.textAlignment, NSTextAlignment) |
| 46 | +RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL) |
| 47 | +RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL) |
| 48 | +RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber) |
| 49 | +RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL) |
| 50 | +RCT_EXPORT_VIEW_PROPERTY(selection, RCTTextSelection) |
| 51 | +RCT_EXPORT_VIEW_PROPERTY(text, NSString) |
| 52 | + |
| 53 | +RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger) |
| 54 | + |
| 55 | +- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView |
| 56 | +{ |
| 57 | + NSNumber *reactTag = shadowView.reactTag; |
| 58 | + UIEdgeInsets borderAsInsets = shadowView.borderAsInsets; |
| 59 | + UIEdgeInsets paddingAsInsets = shadowView.paddingAsInsets; |
| 60 | + return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTBaseTextInputView *> *viewRegistry) { |
| 61 | + RCTBaseTextInputView *view = viewRegistry[reactTag]; |
| 62 | + view.reactBorderInsets = borderAsInsets; |
| 63 | + view.reactPaddingInsets = paddingAsInsets; |
| 64 | + }; |
| 65 | +} |
| 66 | + |
| 67 | +@end |
0 commit comments