Skip to content

Commit f407211

Browse files
christopherdrofacebook-github-bot-2
authored andcommitted
Add keyboardAppearance prop to TextInput component.
Summary: Resolves #3649. Closes facebook/react-native#4012 Reviewed By: javache Differential Revision: D2636538 Pulled By: nicklockwood fb-gh-sync-id: 022e79d8f8fa684cad43af1a51f728d60ac652a8
1 parent c6a3052 commit f407211

6 files changed

Lines changed: 39 additions & 0 deletions

File tree

Examples/UIExplorer/TextInputExample.ios.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,27 @@ exports.examples = [
386386
return <View>{examples}</View>;
387387
}
388388
},
389+
{
390+
title: 'Keyboard appearance',
391+
render: function() {
392+
var keyboardAppearance = [
393+
'default',
394+
'light',
395+
'dark',
396+
];
397+
var examples = keyboardAppearance.map((type) => {
398+
return (
399+
<WithLabel key={type} label={type}>
400+
<TextInput
401+
keyboardAppearance={type}
402+
style={styles.default}
403+
/>
404+
</WithLabel>
405+
);
406+
});
407+
return <View>{examples}</View>;
408+
}
409+
},
389410
{
390411
title: 'Return key types',
391412
render: function() {

Libraries/Components/TextInput/TextInput.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ var TextInput = React.createClass({
161161
'twitter',
162162
'web-search',
163163
]),
164+
/**
165+
* Determines the color of the keyboard.
166+
* @platform ios
167+
*/
168+
keyboardAppearance: PropTypes.oneOf([
169+
'default',
170+
'light',
171+
'dark',
172+
]),
164173
/**
165174
* Determines how the return key should look.
166175
* @platform ios

Libraries/Text/RCTTextFieldManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ - (BOOL)textFieldShouldEndEditing:(RCTTextField *)textField
8686
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
8787
RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
8888
RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)
89+
RCT_EXPORT_VIEW_PROPERTY(keyboardAppearance, UIKeyboardAppearance)
8990
RCT_EXPORT_VIEW_PROPERTY(returnKeyType, UIReturnKeyType)
9091
RCT_EXPORT_VIEW_PROPERTY(enablesReturnKeyAutomatically, BOOL)
9192
RCT_EXPORT_VIEW_PROPERTY(secureTextEntry, BOOL)

Libraries/Text/RCTTextViewManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ - (UIView *)view
3333
RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
3434
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
3535
RCT_REMAP_VIEW_PROPERTY(keyboardType, textView.keyboardType, UIKeyboardType)
36+
RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, textView.keyboardAppearance, UIKeyboardAppearance)
3637
RCT_REMAP_VIEW_PROPERTY(returnKeyType, textView.returnKeyType, UIReturnKeyType)
3738
RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, textView.enablesReturnKeyAutomatically, BOOL)
3839
RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)

React/Base/RCTConvert.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef NSURL RCTFileURL;
6363
+ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)json;
6464
+ (UITextFieldViewMode)UITextFieldViewMode:(id)json;
6565
+ (UIKeyboardType)UIKeyboardType:(id)json;
66+
+ (UIKeyboardAppearance)UIKeyboardAppearance:(id)json;
6667
+ (UIReturnKeyType)UIReturnKeyType:(id)json;
6768

6869
+ (UIViewContentMode)UIViewContentMode:(id)json;

React/Base/RCTConvert.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ + (NSDate *)NSDate:(id)json
272272
@"numeric": @(UIKeyboardTypeDecimalPad),
273273
}), UIKeyboardTypeDefault, integerValue)
274274

275+
RCT_ENUM_CONVERTER(UIKeyboardAppearance, (@{
276+
@"default": @(UIKeyboardAppearanceDefault),
277+
@"light": @(UIKeyboardAppearanceLight),
278+
@"dark": @(UIKeyboardAppearanceDark),
279+
}), UIKeyboardAppearanceDefault, integerValue)
280+
275281
RCT_ENUM_CONVERTER(UIReturnKeyType, (@{
276282
@"default": @(UIReturnKeyDefault),
277283
@"go": @(UIReturnKeyGo),

0 commit comments

Comments
 (0)