-
Notifications
You must be signed in to change notification settings - Fork 751
Expand file tree
/
Copy pathKeyboardTrackingView.ios.tsx
More file actions
51 lines (43 loc) · 1.76 KB
/
KeyboardTrackingView.ios.tsx
File metadata and controls
51 lines (43 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, {PureComponent} from 'react';
import ReactNative, {NativeModules} from 'react-native';
// Import the Codegen specification for New Architecture
import KeyboardTrackingViewNativeComponent from '../../../specs/KeyboardTrackingViewNativeComponent';
import {KeyboardTrackingViewProps} from './index';
const KeyboardTrackingViewTempManager = NativeModules.KeyboardTrackingViewTempManager;
/**
* @description: A UI component that enables "keyboard tracking" for this view and it's sub-views.
* Would typically be used when you have a TextField or TextInput inside this view.
*
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/KeyboardTrackingViewScreen.js
* @notes: This view is useful only for iOS.
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/KeyboardTrackingView/KeyboardTrackingView.gif?raw=true
*/
class KeyboardTrackingView extends PureComponent<KeyboardTrackingViewProps> {
static displayName = 'KeyboardTrackingView';
static defaultProps = {
useSafeArea: false
};
ref?: any;
render() {
return (
<KeyboardTrackingViewNativeComponent
{...this.props}
ref={r => {
this.ref = r;
}}
/>
);
}
async getNativeProps() {
if (this.ref && KeyboardTrackingViewTempManager && KeyboardTrackingViewTempManager.getNativeProps) {
return await KeyboardTrackingViewTempManager.getNativeProps(ReactNative.findNodeHandle(this.ref));
}
return {};
}
scrollToStart() {
if (this.ref && KeyboardTrackingViewTempManager && KeyboardTrackingViewTempManager.scrollToStart) {
KeyboardTrackingViewTempManager.scrollToStart(ReactNative.findNodeHandle(this.ref));
}
}
}
export default KeyboardTrackingView;