2015-04-29 08:29:00 +00:00
|
|
|
/**
|
|
|
|
* 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 "RCTTextViewManager.h"
|
|
|
|
|
|
|
|
#import "RCTBridge.h"
|
|
|
|
#import "RCTConvert.h"
|
|
|
|
#import "RCTShadowView.h"
|
|
|
|
#import "RCTTextView.h"
|
|
|
|
|
|
|
|
@implementation RCTTextViewManager
|
|
|
|
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
|
|
|
- (UIView *)view
|
|
|
|
{
|
|
|
|
return [[RCTTextView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
|
|
|
}
|
|
|
|
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, textView.autocapitalizationType, UITextAutocapitalizationType)
|
2015-04-29 08:29:00 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL)
|
2015-12-02 15:11:20 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
|
2015-04-29 22:55:36 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(color, textView.textColor, UIColor)
|
2016-02-07 20:37:17 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(textAlign, textView.textAlignment, NSTextAlignment)
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(editable, textView.editable, BOOL)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, textView.enablesReturnKeyAutomatically, BOOL)
|
2015-04-29 22:55:36 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(keyboardType, textView.keyboardType, UIKeyboardType)
|
2015-11-11 13:31:18 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, textView.keyboardAppearance, UIKeyboardAppearance)
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber)
|
2016-05-25 13:07:35 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
2015-11-14 17:41:59 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor)
|
2015-04-29 22:55:36 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(returnKeyType, textView.returnKeyType, UIReturnKeyType)
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(secureTextEntry, textView.secureTextEntry, BOOL)
|
2016-02-03 13:48:31 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(selectionColor, tintColor, UIColor)
|
2015-11-24 22:26:14 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
|
2015-04-29 08:29:00 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextView)
|
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
|
|
|
}
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, RCTTextView)
|
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withWeight:json]; // defaults to normal
|
|
|
|
}
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, RCTTextView)
|
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withStyle:json]; // defaults to normal
|
|
|
|
}
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, RCTTextView)
|
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withFamily:json ?: defaultView.font.familyName];
|
|
|
|
}
|
2015-07-21 19:37:24 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
|
2015-04-29 08:29:00 +00:00
|
|
|
|
|
|
|
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView
|
|
|
|
{
|
|
|
|
NSNumber *reactTag = shadowView.reactTag;
|
|
|
|
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
2015-11-14 18:25:00 +00:00
|
|
|
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
|
|
|
|
viewRegistry[reactTag].contentInset = padding;
|
2015-04-29 08:29:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|