Skip to content

Commit

Permalink
Add keyboardAppearance prop to TextInput component.
Browse files Browse the repository at this point in the history
Summary: Resolves #3649.
Closes #4012

Reviewed By: javache

Differential Revision: D2636538

Pulled By: nicklockwood

fb-gh-sync-id: 022e79d8f8fa684cad43af1a51f728d60ac652a8
  • Loading branch information
christopherdro authored and facebook-github-bot-2 committed Nov 11, 2015
1 parent c6a3052 commit f407211
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Examples/UIExplorer/TextInputExample.ios.js
Expand Up @@ -386,6 +386,27 @@ exports.examples = [
return <View>{examples}</View>;
}
},
{
title: 'Keyboard appearance',
render: function() {
var keyboardAppearance = [
'default',
'light',
'dark',
];
var examples = keyboardAppearance.map((type) => {
return (
<WithLabel key={type} label={type}>
<TextInput
keyboardAppearance={type}
style={styles.default}
/>
</WithLabel>
);
});
return <View>{examples}</View>;
}
},
{
title: 'Return key types',
render: function() {
Expand Down
9 changes: 9 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Expand Up @@ -161,6 +161,15 @@ var TextInput = React.createClass({
'twitter',
'web-search',
]),
/**
* Determines the color of the keyboard.
* @platform ios
*/
keyboardAppearance: PropTypes.oneOf([
'default',
'light',
'dark',
]),
/**
* Determines how the return key should look.
* @platform ios
Expand Down
1 change: 1 addition & 0 deletions Libraries/Text/RCTTextFieldManager.m
Expand Up @@ -86,6 +86,7 @@ - (BOOL)textFieldShouldEndEditing:(RCTTextField *)textField
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)
RCT_EXPORT_VIEW_PROPERTY(keyboardAppearance, UIKeyboardAppearance)
RCT_EXPORT_VIEW_PROPERTY(returnKeyType, UIReturnKeyType)
RCT_EXPORT_VIEW_PROPERTY(enablesReturnKeyAutomatically, BOOL)
RCT_EXPORT_VIEW_PROPERTY(secureTextEntry, BOOL)
Expand Down
1 change: 1 addition & 0 deletions Libraries/Text/RCTTextViewManager.m
Expand Up @@ -33,6 +33,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
RCT_REMAP_VIEW_PROPERTY(keyboardType, textView.keyboardType, UIKeyboardType)
RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, textView.keyboardAppearance, UIKeyboardAppearance)
RCT_REMAP_VIEW_PROPERTY(returnKeyType, textView.returnKeyType, UIReturnKeyType)
RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, textView.enablesReturnKeyAutomatically, BOOL)
RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)
Expand Down
1 change: 1 addition & 0 deletions React/Base/RCTConvert.h
Expand Up @@ -63,6 +63,7 @@ typedef NSURL RCTFileURL;
+ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)json;
+ (UITextFieldViewMode)UITextFieldViewMode:(id)json;
+ (UIKeyboardType)UIKeyboardType:(id)json;
+ (UIKeyboardAppearance)UIKeyboardAppearance:(id)json;
+ (UIReturnKeyType)UIReturnKeyType:(id)json;

+ (UIViewContentMode)UIViewContentMode:(id)json;
Expand Down
6 changes: 6 additions & 0 deletions React/Base/RCTConvert.m
Expand Up @@ -272,6 +272,12 @@ + (NSDate *)NSDate:(id)json
@"numeric": @(UIKeyboardTypeDecimalPad),
}), UIKeyboardTypeDefault, integerValue)

RCT_ENUM_CONVERTER(UIKeyboardAppearance, (@{
@"default": @(UIKeyboardAppearanceDefault),
@"light": @(UIKeyboardAppearanceLight),
@"dark": @(UIKeyboardAppearanceDark),
}), UIKeyboardAppearanceDefault, integerValue)

RCT_ENUM_CONVERTER(UIReturnKeyType, (@{
@"default": @(UIReturnKeyDefault),
@"go": @(UIReturnKeyGo),
Expand Down

0 comments on commit f407211

Please sign in to comment.