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 "RCTConvert.h"
|
|
|
|
#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
|
|
|
|
|
|
|
|
- (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
|
|
|
}
|
|
|
|
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(caretHidden)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(autoCorrect)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(enabled)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(placeholder)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(text)
|
2015-02-27 16:40:52 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(clearButtonMode)
|
2015-02-20 04:10:52 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(keyboardType)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(color, textColor)
|
2015-03-17 14:04:39 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(autoCapitalize, RCTTextField)
|
|
|
|
{
|
|
|
|
view.autocapitalizationType = json ? [RCTConvert UITextAutocapitalizationType:json]
|
|
|
|
: defaultView.autocapitalizationType;
|
|
|
|
}
|
2015-03-15 23:08:42 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontSize, RCTTextField)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
|
|
|
}
|
2015-03-15 23:08:42 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontWeight, 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
|
|
|
|
}
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontStyle, RCTTextField)
|
|
|
|
{
|
|
|
|
view.font = [RCTConvert UIFont:view.font withStyle:json]; // defaults to normal
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-15 23:08:42 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(fontFamily, 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) {
|
|
|
|
((RCTTextField *)viewRegistry[reactTag]).paddingEdgeInsets = padding;
|
|
|
|
};
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
@end
|