Skip to content

Commit c58c333

Browse files
Merge branch 'master' into android-support
2 parents 6cfc058 + f4805f2 commit c58c333

File tree

5 files changed

+29
-20
lines changed

5 files changed

+29
-20
lines changed

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
},
1515

1616
"plugins": [
17-
"react"
17+
"react",
18+
"flowtype"
19+
],
20+
21+
"extends": [
22+
"plugin:flowtype/recommended"
1823
],
1924

2025
"globals": {

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9
9393
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
9494

9595
[version]
96-
0.33.0
96+
0.47.0

lib/KeyboardAwareListView.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@ const KeyboardAwareListView = createReactClass({
1010
propTypes: {
1111
viewIsInsideTabBar: PropTypes.bool,
1212
resetScrollToCoords: PropTypes.shape({
13-
x: PropTypes.number,
14-
y: PropTypes.number,
13+
x: PropTypes.number.isRequired,
14+
y: PropTypes.number.isRequired,
1515
}),
16-
enableOnAndroid: React.PropTypes.bool,
16+
onScroll: PropTypes.func,
17+
enableOnAndroid: PropTypes.bool,
1718
},
1819
mixins: [KeyboardAwareMixin],
1920

2021
componentWillMount: function () {
21-
this.setViewIsInsideTabBar(this.props.viewIsInsideTabBar)
22-
this.setResetScrollToCoords(this.props.resetScrollToCoords)
22+
this.setViewIsInsideTabBar(!!this.props.viewIsInsideTabBar)
23+
if (this.props.resetScrollToCoords) {
24+
this.setResetScrollToCoords(this.props.resetScrollToCoords)
25+
}
26+
},
27+
28+
onScroll: function (e: SyntheticEvent & {nativeEvent: {contentOffset: number}}) {
29+
this.handleOnScroll(e)
30+
this.props.onScroll && this.props.onScroll(e)
2331
},
2432

2533
render: function () {
@@ -49,10 +57,7 @@ const KeyboardAwareListView = createReactClass({
4957
scrollEventThrottle={0}
5058
{...this.props}
5159
contentContainerStyle={newContentContainerStyle || contentContainerStyle}
52-
onScroll={e => {
53-
this.handleOnScroll(e)
54-
this.props.onScroll && this.props.onScroll(e)
55-
}}
60+
onScroll={this.onScroll}
5661
/>
5762
)
5863
},

lib/KeyboardAwareMixin.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import PropTypes from 'prop-types'
44
import ReactNative, { TextInput, Keyboard, UIManager, Platform } from 'react-native'
55
import TimerMixin from 'react-timer-mixin'
66

7-
import type { Event } from 'react-native'
8-
97
const _KAM_DEFAULT_TAB_BAR_HEIGHT: number = 49
108
const _KAM_KEYBOARD_OPENING_TIME: number = 250
119
const _KAM_EXTRA_HEIGHT: number = 75
@@ -30,7 +28,7 @@ const KeyboardAwareMixin = {
3028
}
3129
},
3230

33-
setViewIsInsideTabBar: function (viewIsInsideTabBar: bool) {
31+
setViewIsInsideTabBar: function (viewIsInsideTabBar: boolean) {
3432
this.viewIsInsideTabBar = viewIsInsideTabBar
3533
const keyboardSpace = viewIsInsideTabBar ? _KAM_DEFAULT_TAB_BAR_HEIGHT : 0
3634
if (this.state.keyboardSpace !== keyboardSpace) {
@@ -42,7 +40,7 @@ const KeyboardAwareMixin = {
4240
this.resetCoords = coords
4341
},
4442

45-
getInitialState: function (props: Object) {
43+
getInitialState: function () {
4644
this.viewIsInsideTabBar = false
4745
this.keyboardWillShowEvent = undefined
4846
this.keyboardWillHideEvent = undefined
@@ -146,12 +144,12 @@ const KeyboardAwareMixin = {
146144
return this.refs._rnkasv_keyboardView && this.refs._rnkasv_keyboardView.getScrollResponder()
147145
},
148146

149-
scrollToPosition: function (x: number, y: number, animated: bool = true) {
147+
scrollToPosition: function (x: number, y: number, animated: boolean = true) {
150148
const responder = this.getScrollResponder();
151149
responder && responder.scrollResponderScrollTo({x: x, y: y, animated: animated})
152150
},
153151

154-
scrollToEnd: function (animated?: bool = true) {
152+
scrollToEnd: function (animated?: boolean = true) {
155153
const responder = this.getScrollResponder();
156154
responder && responder.scrollResponderScrollToEnd({animated: animated})
157155
},
@@ -198,7 +196,7 @@ const KeyboardAwareMixin = {
198196

199197
defaultResetScrollToCoords: null, // format: {x: 0, y: 0}
200198

201-
handleOnScroll: function (e: Event) {
199+
handleOnScroll: function (e: SyntheticEvent & {nativeEvent: {contentOffset: number}}) {
202200
this.position = e.nativeEvent.contentOffset
203201
},
204202
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"devDependencies": {
4444
"babel-eslint": "^6.0.4",
4545
"eslint": "^3.17.1",
46-
"eslint-plugin-react": "^6.10.0",
47-
"flow-bin": "0.33.0"
46+
"eslint-plugin-flowtype": "^2.35.0",
47+
"eslint-plugin-react": "^7.1.0",
48+
"flow-bin": "0.47.0"
4849
}
4950
}

0 commit comments

Comments
 (0)