Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix keyboard avoidance on Android #161

Merged
merged 2 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
- run: npm install -g yarn
- name: Install dependencies
run: yarn
# - name: Run tests
# run: yarn test
- id: publish
uses: JS-DevTools/npm-publish@v1
with:
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,36 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install -g yarn

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Restore yarn cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn
run: yarn --prefer-offline

- name: Setup React Native environment
run: |
yarn add react-native@0.63.4
yarn add react@16.13.1

- name: Run tests
run: yarn test --coverage

- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
18 changes: 10 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import InfoToast from './components/info';
import { complement } from './utils/arr';
import { includeKeys } from './utils/obj';
import { stylePropType } from './utils/prop-types';
import { isIOS } from './utils/platform';
import styles from './styles';

const FRICTION = 8;
Expand Down Expand Up @@ -126,14 +127,15 @@ class Toast extends Component {
}

componentDidMount() {
this.keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
this.keyboardDidShow
);
this.keyboardDidHideListner = Keyboard.addListener(
'keyboardDidHide',
this.keyboardDidHide
);
const noop = {
remove: () => {}
};
this.keyboardDidShowListener = isIOS
? Keyboard.addListener('keyboardDidShow', this.keyboardDidShow)
: noop;
this.keyboardDidHideListner = isIOS
? Keyboard.addListener('keyboardDidHide', this.keyboardDidHide)
: noop;
}

componentWillUnmount() {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Platform } from 'react-native';

const isIOS = Platform.OS === 'ios';

export { isIOS };