From f407211131b3fdae77e93068407b2e8471f332d9 Mon Sep 17 00:00:00 2001 From: Christopher Dro Date: Wed, 11 Nov 2015 05:31:18 -0800 Subject: [PATCH] Add keyboardAppearance prop to TextInput component. Summary: Resolves #3649. Closes https://github.com/facebook/react-native/pull/4012 Reviewed By: javache Differential Revision: D2636538 Pulled By: nicklockwood fb-gh-sync-id: 022e79d8f8fa684cad43af1a51f728d60ac652a8 --- Examples/UIExplorer/TextInputExample.ios.js | 21 +++++++++++++++++++++ Libraries/Components/TextInput/TextInput.js | 9 +++++++++ Libraries/Text/RCTTextFieldManager.m | 1 + Libraries/Text/RCTTextViewManager.m | 1 + React/Base/RCTConvert.h | 1 + React/Base/RCTConvert.m | 6 ++++++ 6 files changed, 39 insertions(+) diff --git a/Examples/UIExplorer/TextInputExample.ios.js b/Examples/UIExplorer/TextInputExample.ios.js index c7e196222..92359b178 100644 --- a/Examples/UIExplorer/TextInputExample.ios.js +++ b/Examples/UIExplorer/TextInputExample.ios.js @@ -386,6 +386,27 @@ exports.examples = [ return {examples}; } }, + { + title: 'Keyboard appearance', + render: function() { + var keyboardAppearance = [ + 'default', + 'light', + 'dark', + ]; + var examples = keyboardAppearance.map((type) => { + return ( + + + + ); + }); + return {examples}; + } + }, { title: 'Return key types', render: function() { diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 68b83e0c1..f9601fe33 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -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 diff --git a/Libraries/Text/RCTTextFieldManager.m b/Libraries/Text/RCTTextFieldManager.m index 88a59e1bd..c5e73790d 100644 --- a/Libraries/Text/RCTTextFieldManager.m +++ b/Libraries/Text/RCTTextFieldManager.m @@ -86,6 +86,7 @@ RCT_REMAP_VIEW_PROPERTY(clearTextOnFocus, clearsOnBeginEditing, BOOL) 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) diff --git a/Libraries/Text/RCTTextViewManager.m b/Libraries/Text/RCTTextViewManager.m index f47a106bd..1575beef6 100644 --- a/Libraries/Text/RCTTextViewManager.m +++ b/Libraries/Text/RCTTextViewManager.m @@ -33,6 +33,7 @@ RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber) 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) diff --git a/React/Base/RCTConvert.h b/React/Base/RCTConvert.h index 7dbcab6d8..35106a694 100644 --- a/React/Base/RCTConvert.h +++ b/React/Base/RCTConvert.h @@ -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; diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index fb6ef99dd..2531b69b9 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -272,6 +272,12 @@ RCT_ENUM_CONVERTER(UIKeyboardType, (@{ @"numeric": @(UIKeyboardTypeDecimalPad), }), UIKeyboardTypeDefault, integerValue) +RCT_ENUM_CONVERTER(UIKeyboardAppearance, (@{ + @"default": @(UIKeyboardAppearanceDefault), + @"light": @(UIKeyboardAppearanceLight), + @"dark": @(UIKeyboardAppearanceDark), +}), UIKeyboardAppearanceDefault, integerValue) + RCT_ENUM_CONVERTER(UIReturnKeyType, (@{ @"default": @(UIReturnKeyDefault), @"go": @(UIReturnKeyGo),