Skip to content

Commit e215b37

Browse files
committed
Merge pull request #14 from APSL/iss_12
closes #12 #13
2 parents 4b125cb + c9e84cb commit e215b37

File tree

6 files changed

+127
-7
lines changed

6 files changed

+127
-7
lines changed

.flowconfig

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*.web.js
5+
.*/*.android.js
6+
7+
# Some modules have their own node_modules with overlap
8+
.*/node_modules/node-haste/.*
9+
10+
# Ugh
11+
.*/node_modules/babel.*
12+
.*/node_modules/babylon.*
13+
.*/node_modules/invariant.*
14+
15+
# Ignore react and fbjs where there are overlaps, but don't ignore
16+
# anything that react-native relies on
17+
.*/node_modules/fbjs/lib/Map.js
18+
.*/node_modules/fbjs/lib/fetch.js
19+
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
20+
.*/node_modules/fbjs/lib/ErrorUtils.js
21+
22+
# Flow has a built-in definition for the 'react' module which we prefer to use
23+
# over the currently-untyped source
24+
.*/node_modules/react/react.js
25+
.*/node_modules/react/lib/React.js
26+
.*/node_modules/react/lib/ReactDOM.js
27+
28+
.*/__mocks__/.*
29+
.*/__tests__/.*
30+
31+
.*/commoner/test/source/widget/share.js
32+
33+
# Ignore commoner tests
34+
.*/node_modules/commoner/test/.*
35+
36+
# See https://github.com/facebook/flow/issues/442
37+
.*/react-tools/node_modules/commoner/lib/reader.js
38+
39+
# Ignore jest
40+
.*/node_modules/jest-cli/.*
41+
42+
# Ignore Website
43+
.*/website/.*
44+
45+
# Ignore generators
46+
.*/local-cli/generator.*
47+
48+
# Ignore BUCK generated folders
49+
.*\.buckd/
50+
51+
.*/node_modules/is-my-json-valid/test/.*\.json
52+
.*/node_modules/iconv-lite/encodings/tables/.*\.json
53+
.*/node_modules/y18n/test/.*\.json
54+
.*/node_modules/spdx-license-ids/spdx-license-ids.json
55+
.*/node_modules/spdx-exceptions/index.json
56+
.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
57+
.*/node_modules/resolve/lib/core.json
58+
.*/node_modules/jsonparse/samplejson/.*\.json
59+
.*/node_modules/json5/test/.*\.json
60+
.*/node_modules/ua-parser-js/test/.*\.json
61+
.*/node_modules/builtin-modules/builtin-modules.json
62+
.*/node_modules/binary-extensions/binary-extensions.json
63+
.*/node_modules/url-regex/tlds.json
64+
.*/node_modules/joi/.*\.json
65+
.*/node_modules/isemail/.*\.json
66+
.*/node_modules/tr46/.*\.json
67+
68+
69+
[include]
70+
71+
[libs]
72+
node_modules/react-native/Libraries/react-native/react-native-interface.js
73+
node_modules/react-native/flow
74+
flow/
75+
76+
[options]
77+
module.system=haste
78+
79+
esproposal.class_static_fields=enable
80+
esproposal.class_instance_fields=enable
81+
82+
munge_underscores=true
83+
84+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
85+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
86+
87+
suppress_type=$FlowIssue
88+
suppress_type=$FlowFixMe
89+
suppress_type=$FixMe
90+
91+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
92+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
93+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
94+
95+
[version]
96+
0.23.0

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ _scrollToInput (event, reactNode) {
5050
</KeyboardAwareScrollView>
5151
```
5252

53+
## Register to keyboard events
54+
You can register to `ScrollViewResponder` events `onKeyboardWillShow` and `onKeyboardWillHide`:
55+
56+
```js
57+
<KeyboardAwareScrollView
58+
onKeyboardWillShow={(frames: Object) => {
59+
console.log('Keyboard event', frames)
60+
}}>
61+
<View>
62+
<TextInput />
63+
</View>
64+
</KeyboardAwareScrollView>
65+
```
66+
5367
## License
5468

5569
MIT.

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @flow */
2+
13
import KeyboardAwareMixin from './lib/KeyboardAwareMixin'
24
import KeyboardAwareScrollView from './lib/KeyboardAwareScrollView'
35
import KeyboardAwareListView from './lib/KeyboardAwareListView'

lib/KeyboardAwareListView.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import React, { ListView } from 'react-native'
1+
/* @flow */
2+
3+
import React, { PropTypes } from 'react'
4+
import { ListView } from 'react-native'
25
import KeyboardAwareMixin from './KeyboardAwareMixin'
36

47
const KeyboardAwareListView = React.createClass({

lib/KeyboardAwareMixin.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @flow */
2+
13
import { DeviceEventEmitter } from 'react-native'
24
import TimerMixin from 'react-timer-mixin'
35

@@ -6,12 +8,12 @@ const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49
68
const KeyboardAwareMixin = {
79
mixins: [TimerMixin],
810

9-
setViewIsInsideTabBar: function (viewIsInsideTabBar) {
11+
setViewIsInsideTabBar: function (viewIsInsideTabBar: bool) {
1012
this.viewIsInsideTabBar = viewIsInsideTabBar
1113
this.setState({keyboardSpace: _KAM_DEFAULT_TAB_BAR_HEIGHT})
1214
},
1315

14-
getInitialState: function (props) {
16+
getInitialState: function (props: Object) {
1517
this.viewIsInsideTabBar = false
1618
this.keyboardWillShowEvent = undefined
1719
this.keyboardWillHideEvent = undefined
@@ -21,7 +23,7 @@ const KeyboardAwareMixin = {
2123
},
2224

2325
// Keyboard actions
24-
updateKeyboardSpace: function (frames) {
26+
updateKeyboardSpace: function (frames: Object) {
2527
const keyboardSpace = (this.props.viewIsInsideTabBar) ? frames.endCoordinates.height - _KAM_DEFAULT_TAB_BAR_HEIGHT : frames.endCoordinates.height
2628
this.setState({
2729
keyboardSpace: keyboardSpace,
@@ -49,7 +51,7 @@ const KeyboardAwareMixin = {
4951
/**
5052
* @param extraHeight: takes an extra height in consideration.
5153
*/
52-
scrollToFocusedInput: function (event, reactNode, extraHeight = _KAM_DEFAULT_TAB_BAR_HEIGHT) {
54+
scrollToFocusedInput: function (event: Object, reactNode: Object, extraHeight: number = _KAM_DEFAULT_TAB_BAR_HEIGHT) {
5355
const scrollView = this.refs.keyboardView.getScrollResponder()
5456
this.setTimeout(() => {
5557
scrollView.scrollResponderScrollNativeHandleToKeyboard(

lib/KeyboardAwareScrollView.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import React, { ScrollView } from 'react-native'
1+
/* @flow */
2+
3+
import React, { PropTypes } from 'react'
4+
import { ScrollView } from 'react-native'
25
import KeyboardAwareMixin from './KeyboardAwareMixin'
36

47
const KeyboardAwareScrollView = React.createClass({
58
propTypes: {
69
...ScrollView.propTypes,
7-
viewIsInsideTabBar: React.PropTypes.bool,
10+
viewIsInsideTabBar: PropTypes.bool,
811
},
912
mixins: [KeyboardAwareMixin],
1013

0 commit comments

Comments
 (0)