(
ScrollableComponent: React$Component,
userOptions: KeyboardAwareHOCOptions = {}
)
| 142 | } |
| 143 | |
| 144 | function KeyboardAwareHOC( |
| 145 | ScrollableComponent: React$Component, |
| 146 | userOptions: KeyboardAwareHOCOptions = {} |
| 147 | ) { |
| 148 | const hocOptions: KeyboardAwareHOCOptions = { |
| 149 | ...ScrollIntoViewDefaultOptions, |
| 150 | ...userOptions |
| 151 | } |
| 152 | |
| 153 | return class |
| 154 | extends React.Component<KeyboardAwareHOCProps, KeyboardAwareHOCState> |
| 155 | implements KeyboardAwareInterface { |
| 156 | _rnkasv_keyboardView: any |
| 157 | keyboardWillShowEvent: ?Function |
| 158 | keyboardWillHideEvent: ?Function |
| 159 | position: ContentOffset |
| 160 | defaultResetScrollToCoords: ?{ x: number, y: number } |
| 161 | mountedComponent: boolean |
| 162 | handleOnScroll: Function |
| 163 | state: KeyboardAwareHOCState |
| 164 | static displayName = `KeyboardAware${getDisplayName(ScrollableComponent)}` |
| 165 | |
| 166 | static propTypes = { |
| 167 | viewIsInsideTabBar: PropTypes.bool, |
| 168 | resetScrollToCoords: PropTypes.shape({ |
| 169 | x: PropTypes.number.isRequired, |
| 170 | y: PropTypes.number.isRequired |
| 171 | }), |
| 172 | enableResetScrollToCoords: PropTypes.bool, |
| 173 | enableAutomaticScroll: PropTypes.bool, |
| 174 | extraHeight: PropTypes.number, |
| 175 | extraScrollHeight: PropTypes.number, |
| 176 | keyboardOpeningTime: PropTypes.number, |
| 177 | onScroll: PropTypes.oneOfType([ |
| 178 | PropTypes.func, // Normal listener |
| 179 | PropTypes.object // Animated.event listener |
| 180 | ]), |
| 181 | update: PropTypes.func, |
| 182 | contentContainerStyle: PropTypes.any, |
| 183 | enableOnAndroid: PropTypes.bool, |
| 184 | innerRef: PropTypes.func, |
| 185 | ...keyboardEventPropTypes |
| 186 | } |
| 187 | |
| 188 | // HOC options are used to init default props, so that these options can be overriden with component props |
| 189 | static defaultProps = { |
| 190 | enableAutomaticScroll: hocOptions.enableAutomaticScroll, |
| 191 | extraHeight: hocOptions.extraHeight, |
| 192 | extraScrollHeight: hocOptions.extraScrollHeight, |
| 193 | enableResetScrollToCoords: hocOptions.enableResetScrollToCoords, |
| 194 | keyboardOpeningTime: hocOptions.keyboardOpeningTime, |
| 195 | viewIsInsideTabBar: hocOptions.viewIsInsideTabBar, |
| 196 | enableOnAndroid: hocOptions.enableOnAndroid |
| 197 | } |
| 198 | |
| 199 | constructor(props: KeyboardAwareHOCProps) { |
| 200 | super(props) |
| 201 | this.keyboardWillShowEvent = undefined |
no outgoing calls
no test coverage detected
searching dependent graphs…