From 6b96f9fd8f6f918bb6b3ed20aab3c50f7eb37047 Mon Sep 17 00:00:00 2001 From: Douglas Nassif Roma Junior Date: Sat, 23 Sep 2017 11:25:05 -0300 Subject: [PATCH] Exposed PreviousNextView to wrap TextInput and solve the problem of navigating between fields in Modal. #8 --- Sample/index.ios.js | 39 ++++++++++++------- .../project.pbxproj | 2 +- index.js | 7 ++-- .../project.pbxproj | 6 +++ .../RNKMPreviousNextViewManager.h | 28 +++++++++++++ .../RNKMPreviousNextViewManager.m | 34 ++++++++++++++++ 6 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.h create mode 100644 ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.m diff --git a/Sample/index.ios.js b/Sample/index.ios.js index c33112b..6e06515 100644 --- a/Sample/index.ios.js +++ b/Sample/index.ios.js @@ -31,9 +31,10 @@ import { TextInput, ScrollView, Switch, + Modal, } from 'react-native'; -import KeyboardManager from 'react-native-keyboard-manager' +import KeyboardManager, { PreviousNextView } from 'react-native-keyboard-manager' KeyboardManager.setEnable(true); KeyboardManager.setEnableDebugging(false); @@ -42,7 +43,7 @@ KeyboardManager.setPreventShowingBottomBlankSpace(true); KeyboardManager.setEnableAutoToolbar(true); KeyboardManager.setToolbarDoneBarButtonItemText("Close"); KeyboardManager.setToolbarManageBehaviour(0); -KeyboardManager.setToolbarPreviousNextButtonEnable(false); +KeyboardManager.setToolbarPreviousNextButtonEnable(true); KeyboardManager.setShouldToolbarUsesTextFieldTintColor(false); KeyboardManager.setShouldShowTextFieldPlaceholder(true); KeyboardManager.setOverrideKeyboardAppearance(false); @@ -116,20 +117,30 @@ class SampleKeyboardManager extends Component { return ( - {/* ScrollView is not required, but may be required in some cases. */} - - - React-Native Keyboard Manager - - Enable/Disable - - - + {/* To try with Modal, uncomment the two following lines. */} + {/* */} + {/* */} + + {/* ScrollView is not required, but may be needed in some cases. */} + + + + React-Native Keyboard Manager + + Enable/Disable + + + + + {inputs} + + + + {/* */} + {/* */} - {inputs} - ) } diff --git a/Sample/ios/SampleKeyboardManager.xcodeproj/project.pbxproj b/Sample/ios/SampleKeyboardManager.xcodeproj/project.pbxproj index e932a54..e3c6a04 100644 --- a/Sample/ios/SampleKeyboardManager.xcodeproj/project.pbxproj +++ b/Sample/ios/SampleKeyboardManager.xcodeproj/project.pbxproj @@ -960,7 +960,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; }; 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = { isa = PBXShellScriptBuildPhase; diff --git a/index.js b/index.js index ae1e3aa..7a930d9 100644 --- a/index.js +++ b/index.js @@ -23,11 +23,10 @@ */ import { - NativeModules, DeviceEventEmitter + NativeModules, DeviceEventEmitter, requireNativeComponent, } from 'react-native'; const KeyboardManager = NativeModules.ReactNativeKeyboardManager; +export default KeyboardManager; -module.exports = KeyboardManager; - - +export const PreviousNextView = requireNativeComponent('RNKMPreviousNextView'); diff --git a/ios/ReactNativeKeyboardManager.xcodeproj/project.pbxproj b/ios/ReactNativeKeyboardManager.xcodeproj/project.pbxproj index dd338e4..59e4963 100644 --- a/ios/ReactNativeKeyboardManager.xcodeproj/project.pbxproj +++ b/ios/ReactNativeKeyboardManager.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ A51184261EFAD3660077C68F /* IQToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = A51184151EFAD3660077C68F /* IQToolbar.m */; }; A51184271EFAD3660077C68F /* IQUIView+IQKeyboardToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = A51184171EFAD3660077C68F /* IQUIView+IQKeyboardToolbar.m */; }; A54A31CD1F42442A00950C4B /* IQKeyboardManager.bundle in Sources */ = {isa = PBXBuildFile; fileRef = A54A31CC1F4243FF00950C4B /* IQKeyboardManager.bundle */; }; + A5A1B05A1F76A1FF000B2090 /* RNKMPreviousNextViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A5A1B0591F76A1FE000B2090 /* RNKMPreviousNextViewManager.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -75,6 +76,8 @@ A51184171EFAD3660077C68F /* IQUIView+IQKeyboardToolbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "IQUIView+IQKeyboardToolbar.m"; sourceTree = ""; }; A51184191EFAD3660077C68F /* IQKeyboardManager.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = IQKeyboardManager.bundle; sourceTree = ""; }; A54A31CC1F4243FF00950C4B /* IQKeyboardManager.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = IQKeyboardManager.bundle; sourceTree = ""; }; + A5A1B0581F76A1FE000B2090 /* RNKMPreviousNextViewManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNKMPreviousNextViewManager.h; sourceTree = ""; }; + A5A1B0591F76A1FE000B2090 /* RNKMPreviousNextViewManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNKMPreviousNextViewManager.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -111,6 +114,8 @@ A511835A1EFAC0300077C68F /* ReactNativeKeyboardManager */ = { isa = PBXGroup; children = ( + A5A1B0581F76A1FE000B2090 /* RNKMPreviousNextViewManager.h */, + A5A1B0591F76A1FE000B2090 /* RNKMPreviousNextViewManager.m */, A511835B1EFAC0300077C68F /* ReactNativeKeyboardManager.h */, A511835C1EFAC0300077C68F /* ReactNativeKeyboardManager.m */, ); @@ -268,6 +273,7 @@ A511841A1EFAD3660077C68F /* IQNSArray+Sort.m in Sources */, A511841B1EFAD3660077C68F /* IQUIScrollView+Additions.m in Sources */, A51184231EFAD3660077C68F /* IQBarButtonItem.m in Sources */, + A5A1B05A1F76A1FF000B2090 /* RNKMPreviousNextViewManager.m in Sources */, A511841F1EFAD3660077C68F /* IQUIWindow+Hierarchy.m in Sources */, A51184221EFAD3660077C68F /* IQTextView.m in Sources */, A511841C1EFAD3660077C68F /* IQUITextFieldView+Additions.m in Sources */, diff --git a/ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.h b/ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.h new file mode 100644 index 0000000..d5cbb61 --- /dev/null +++ b/ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.h @@ -0,0 +1,28 @@ +// MIT License +// +// Copyright (c) 2017 Douglas Nassif Roma Junior +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "IQPreviousNextView.h" + +#import + +@interface RNKMPreviousNextViewManager : RCTViewManager +@end diff --git a/ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.m b/ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.m new file mode 100644 index 0000000..51aa5d2 --- /dev/null +++ b/ios/ReactNativeKeyboardManager/RNKMPreviousNextViewManager.m @@ -0,0 +1,34 @@ +// MIT License +// +// Copyright (c) 2017 Douglas Nassif Roma Junior +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "RNKMPreviousNextViewManager.h" + +@implementation RNKMPreviousNextViewManager + +RCT_EXPORT_MODULE() + +- (UIView *)view +{ + return [[IQPreviousNextView alloc] init]; +} + +@end