Skip to content

Commit

Permalink
Update IQKeyboardManager to 7.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasjunior committed May 2, 2024
1 parent 8b13527 commit bbfef6e
Show file tree
Hide file tree
Showing 32 changed files with 6,548 additions and 6,315 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
extends: '@react-native',
};
2 changes: 1 addition & 1 deletion ReactNativeKeyboardManager.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Pod::Spec.new do |s|
s.license = packageJson["license"]
s.authors = packageJson["author"]
s.source = { :git => repository, :tag => version }
s.platform = :ios, "9.0"
s.platform = :ios, "13.0"
s.preserve_paths = 'README.md', 'package.json', '*.js'
s.source_files = 'ios/ReactNativeKeyboardManager/**/*.{h,m}'

Expand Down
6 changes: 0 additions & 6 deletions Sample/.buckconfig

This file was deleted.

14 changes: 1 addition & 13 deletions Sample/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/no-shadow': ['error'],
'no-shadow': 'off',
'no-undef': 'off',
},
},
],
extends: '@react-native',
};
33 changes: 23 additions & 10 deletions Sample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
**/.xcode.env.local

# Android/IntelliJ
#
Expand All @@ -29,33 +30,45 @@ build/
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
2 changes: 1 addition & 1 deletion Sample/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
99 changes: 62 additions & 37 deletions Sample/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
Modal,
SafeAreaView,
Platform,
Keyboard,
Button,
} from 'react-native';

import KeyboardManager, {PreviousNextView} from 'react-native-keyboard-manager';
Expand All @@ -43,14 +45,14 @@ if (Platform.OS === 'ios') {
KeyboardManager.setLayoutIfNeededOnUpdate(true);
KeyboardManager.setEnableAutoToolbar(true);
KeyboardManager.setToolbarDoneBarButtonItemText('Done');
KeyboardManager.setToolbarManageBehaviourBy('subviews'); // "subviews" | "tag" | "position"
KeyboardManager.setToolbarManageBehavior('subviews'); // "subviews" | "tag" | "position"
KeyboardManager.setToolbarPreviousNextButtonEnable(true);
KeyboardManager.setToolbarTintColor('#FF00FF'); // Only #000000 format is supported
KeyboardManager.setToolbarBarTintColor('#FFFF00'); // Only #000000 format is supported
KeyboardManager.setShouldShowToolbarPlaceholder(true);
KeyboardManager.setOverrideKeyboardAppearance(false);
KeyboardManager.setToolbarShowPlaceholder(true);
KeyboardManager.setKeyboardOverrideAppearance(false);
KeyboardManager.setKeyboardAppearance('default'); // "default" | "light" | "dark"
KeyboardManager.setShouldResignOnTouchOutside(true);
KeyboardManager.setResignOnTouchOutside(true);
KeyboardManager.setShouldPlayInputClicks(true);
}

Expand All @@ -68,6 +70,7 @@ const INPUT_KEYS = [
];

type StateType = {
modalVisible?: boolean;
enableDisable?: boolean;
inputsValues: {
[key: string]: string;
Expand All @@ -79,6 +82,7 @@ class App extends Component<any, StateType> {
super(props);

this.state = {
modalVisible: false,
enableDisable: true,
inputsValues: {},
};
Expand All @@ -89,18 +93,28 @@ class App extends Component<any, StateType> {
}

componentDidUpdate() {
KeyboardManager.isKeyboardShowing().then(isShowing => {
console.log('isKeyboardShowing: ' + isShowing);
});
console.log('isKeyboardShowing: ' + Keyboard.isVisible());
}

onEnableDisable = (value: boolean) => {
handleEnableDisable = (value: boolean) => {
KeyboardManager.setEnable(value);
this.setState({
enableDisable: value,
});
};

handleShowModal = () => {
this.setState({
modalVisible: true,
});
};

handleCloseModal = () => {
this.setState({
modalVisible: false,
});
};

getRef<T>(key: string) {
// eslint-disable-next-line react/no-string-refs
return this.refs[key] as T;
Expand Down Expand Up @@ -156,39 +170,50 @@ class App extends Component<any, StateType> {
);
};

renderContent = () => {
return (
<ScrollView>
<View style={{alignItems: 'center'}}>
<Text style={{marginTop: 10, textAlign: 'center'}}>
React-Native Keyboard Manager
</Text>
<View
style={{
marginTop: 10,
flexDirection: 'row',
alignItems: 'center',
}}>
<Text>Enable/Disable </Text>
<Switch
onValueChange={this.handleEnableDisable}
value={this.state.enableDisable}
/>
</View>
</View>

<View>{INPUT_KEYS.map(this.renderInput)}</View>
</ScrollView>
);
};

render() {
return (
<View style={{flex: 1}}>
<SafeAreaView style={{flex: 1}}>
{/* To try with Modal, uncomment the two following lines. */}
{/* <Modal visible={true}> */}
{/* <PreviousNextView style={{flex: 1}}> */}

{/* ScrollView is not required, but may be needed in some cases. */}
<ScrollView>
<View style={{alignItems: 'center'}}>
<Text style={{marginTop: 10, textAlign: 'center'}}>
React-Native Keyboard Manager
</Text>
<View
style={{
marginTop: 10,
flexDirection: 'row',
alignItems: 'center',
}}>
<Text>Enable/Disable </Text>
<Switch
onValueChange={this.onEnableDisable}
value={this.state.enableDisable}
/>
</View>
</View>

<View>{INPUT_KEYS.map(this.renderInput)}</View>
</ScrollView>

{/* </PreviousNextView> */}
{/* </Modal> */}
<Button onPress={this.handleShowModal} title="Show in modal" />
{this.renderContent()}

<Modal
onRequestClose={this.handleCloseModal}
visible={this.state.modalVisible}>
<SafeAreaView style={{flex: 1, backgroundColor: '#e1e1e1'}}>
<Button onPress={this.handleCloseModal} title="Close modal" />
{/* Inside a native modal the inputs need to be wrapped inside PreviousNextView */}
<PreviousNextView style={{flex: 1}}>
{this.renderContent()}
</PreviousNextView>
</SafeAreaView>
</Modal>
</SafeAreaView>
</View>
);
Expand Down
79 changes: 79 additions & 0 deletions Sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).

# Getting Started

>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
## Step 1: Start the Metro Server

First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.

To start Metro, run the following command from the _root_ of your React Native project:

```bash
# using npm
npm start

# OR using Yarn
yarn start
```

## Step 2: Start your Application

Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:

### For Android

```bash
# using npm
npm run android

# OR using Yarn
yarn android
```

### For iOS

```bash
# using npm
npm run ios

# OR using Yarn
yarn ios
```

If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

## Step 3: Modifying your App

Now that you have successfully run the app, let's modify it.

1. Open `App.tsx` in your text editor of choice and edit some lines.
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!

For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!

## Congratulations! :tada:

You've successfully run and modified your React Native App. :partying_face:

### Now what?

- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).

# Troubleshooting

If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.

# Learn More

To learn more about React Native, take a look at the following resources:

- [React Native Website](https://reactnative.dev) - learn more about React Native.
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'react-native';
import React from 'react';
import App from '../App';

// Note: import explicitly to use the types shipped with jest.
import {it} from '@jest/globals';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

Expand Down
2 changes: 1 addition & 1 deletion Sample/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ReactNativeKeyboardManagerSample",
"displayName": "ReactNativeKeyboardManagerSample"
}
}
2 changes: 1 addition & 1 deletion Sample/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
presets: ['module:@react-native/babel-preset'],
};
2 changes: 1 addition & 1 deletion Sample/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
rm -rf ../node_modules/
rm -rf node_modules/
rm -rf ios/Pods
rm -rf ios/LibrarySample.xcworkspace
rm -rf ios/ReactNativeKeyboardManagerSample.xcworkspace

yarn install

Expand Down
11 changes: 11 additions & 0 deletions Sample/ios/.xcode.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.

# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
# . "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)
Loading

0 comments on commit bbfef6e

Please sign in to comment.