Skip to content

Commit

Permalink
fix keyboard avoidance on Android (#161)
Browse files Browse the repository at this point in the history
* fix keyboard avoidance on android

* use cache on test workflow
  • Loading branch information
calintamas committed Mar 2, 2021
1 parent 3117999 commit 3d31fac
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
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 };

0 comments on commit 3d31fac

Please sign in to comment.