2015-03-23 20:28:42 +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.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import "RCTTextFieldManager.h"
|
|
|
|
|
2015-03-17 10:51:58 +00:00
|
|
|
#import "RCTBridge.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
#import "RCTShadowView.h"
|
2015-03-01 23:33:55 +00:00
|
|
|
#import "RCTSparseArray.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
#import "RCTTextField.h"
|
|
|
|
|
|
|
|
@implementation RCTTextFieldManager
|
|
|
|
|
2015-04-08 12:42:43 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
2015-03-06 00:36:41 +00:00
|
|
|
return [[RCTTextField alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(caretHidden, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString)
|
2015-04-27 17:24:49 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(clearButtonMode, UITextFieldViewMode)
|
2015-04-15 00:51:28 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(clearTextOnFocus, clearsOnBeginEditing, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)
|
2015-03-31 01:25:30 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(returnKeyType, UIReturnKeyType)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(enablesReturnKeyAutomatically, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(secureTextEntry, BOOL)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType)
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextField)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
|
|
|
}
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, RCTTextField)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-25 23:22:59 +00:00
|
|
|
view.font = [RCTConvert UIFont:view.font withWeight:json]; // defaults to normal
|
|
|
|
}
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, RCTTextField)
|
2015-03-25 23:22:59 +00:00
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withStyle:json]; // defaults to normal
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, RCTTextField)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withFamily:json ?: defaultView.font.familyName];
|
|
|
|
}
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView
|
|
|
|
{
|
|
|
|
NSNumber *reactTag = shadowView.reactTag;
|
|
|
|
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
|
|
|
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
2015-03-27 16:36:33 +00:00
|
|
|
((RCTTextField *)viewRegistry[reactTag]).contentInset = padding;
|
2015-03-01 23:33:55 +00:00
|
|
|
};
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
@end
|