-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RCTBaseTextInputViewManager: new base class for TextInput view managers
Summary: Bunch or identical code was moved to superclass. Reviewed By: mmmulani Differential Revision: D6663772 fbshipit-source-id: 82321f56bbab0e9d17c0227c97dd86904cf5ab30
- Loading branch information
1 parent
176a578
commit c491b22
Showing
7 changed files
with
95 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import <React/RCTViewManager.h> | ||
|
||
@interface RCTBaseTextInputViewManager : RCTViewManager | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "RCTBaseTextInputViewManager.h" | ||
|
||
#import <React/RCTBridge.h> | ||
#import <React/RCTConvert.h> | ||
#import <React/RCTFont.h> | ||
#import <React/RCTShadowView+Layout.h> | ||
#import <React/RCTShadowView.h> | ||
|
||
#import "RCTConvert+Text.h" | ||
#import "RCTBaseTextInputView.h" | ||
|
||
@implementation RCTBaseTextInputViewManager | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
#pragma mark - Unified <TextInput> properties | ||
|
||
RCT_REMAP_VIEW_PROPERTY(allowFontScaling, fontAttributes.allowFontScaling, BOOL) | ||
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType) | ||
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType) | ||
RCT_REMAP_VIEW_PROPERTY(color, backedTextInputView.textColor, UIColor) | ||
RCT_REMAP_VIEW_PROPERTY(editable, backedTextInputView.editable, BOOL) | ||
RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, backedTextInputView.enablesReturnKeyAutomatically, BOOL) | ||
RCT_REMAP_VIEW_PROPERTY(fontSize, fontAttributes.fontSize, NSNumber) | ||
RCT_REMAP_VIEW_PROPERTY(fontWeight, fontAttributes.fontWeight, NSString) | ||
RCT_REMAP_VIEW_PROPERTY(fontStyle, fontAttributes.fontStyle, NSString) | ||
RCT_REMAP_VIEW_PROPERTY(fontFamily, fontAttributes.fontFamily, NSString) | ||
RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, backedTextInputView.keyboardAppearance, UIKeyboardAppearance) | ||
RCT_REMAP_VIEW_PROPERTY(keyboardType, backedTextInputView.keyboardType, UIKeyboardType) | ||
RCT_REMAP_VIEW_PROPERTY(placeholder, backedTextInputView.placeholder, NSString) | ||
RCT_REMAP_VIEW_PROPERTY(placeholderTextColor, backedTextInputView.placeholderColor, UIColor) | ||
RCT_REMAP_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) | ||
RCT_REMAP_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) | ||
RCT_REMAP_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) | ||
RCT_REMAP_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) | ||
RCT_REMAP_VIEW_PROPERTY(textAlign, backedTextInputView.textAlignment, NSTextAlignment) | ||
RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL) | ||
RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL) | ||
RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber) | ||
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL) | ||
RCT_EXPORT_VIEW_PROPERTY(selection, RCTTextSelection) | ||
RCT_EXPORT_VIEW_PROPERTY(text, NSString) | ||
|
||
RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger) | ||
|
||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView | ||
{ | ||
NSNumber *reactTag = shadowView.reactTag; | ||
UIEdgeInsets borderAsInsets = shadowView.borderAsInsets; | ||
UIEdgeInsets paddingAsInsets = shadowView.paddingAsInsets; | ||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTBaseTextInputView *> *viewRegistry) { | ||
RCTBaseTextInputView *view = viewRegistry[reactTag]; | ||
view.reactBorderInsets = borderAsInsets; | ||
view.reactPaddingInsets = paddingAsInsets; | ||
}; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters