mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
cd9adda651
Summary: The files in `ReactAndroid/src/androidTest/js` use Haste names; this commit migrates them to use path-based imports. This helps us move RN towards standard path-based requires. All the requires in `androidTest` have been rewritten to use relative requires. [General] [Changed] - Migrate "androidTest" JS from Haste to path-based requires Pull Request resolved: https://github.com/facebook/react-native/pull/24813 Differential Revision: D15318108 Pulled By: cpojer fbshipit-source-id: dddc68f992b8dea48afb01fd4481bd5b846231ca
79 lines
1.8 KiB
JavaScript
79 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const React = require('react');
|
|
const {NativeModules, StyleSheet, View} = require('react-native');
|
|
|
|
const {Recording} = NativeModules;
|
|
|
|
const extractSingleTouch = nativeEvent => {
|
|
const touches = nativeEvent.touches;
|
|
const changedTouches = nativeEvent.changedTouches;
|
|
const hasTouches = touches && touches.length > 0;
|
|
const hasChangedTouches = changedTouches && changedTouches.length > 0;
|
|
|
|
return !hasTouches && hasChangedTouches
|
|
? changedTouches[0]
|
|
: hasTouches
|
|
? touches[0]
|
|
: nativeEvent;
|
|
};
|
|
|
|
class TouchTestApp extends React.Component {
|
|
handleStartShouldSetResponder = e => {
|
|
return true;
|
|
};
|
|
|
|
handleOnResponderMove = e => {
|
|
e = extractSingleTouch(e.nativeEvent);
|
|
Recording.record('move;' + e.touches.length);
|
|
};
|
|
|
|
handleResponderStart = e => {
|
|
e = extractSingleTouch(e.nativeEvent);
|
|
if (e.touches) {
|
|
Recording.record('start;' + e.touches.length);
|
|
} else {
|
|
Recording.record('start;ExtraPointer');
|
|
}
|
|
};
|
|
|
|
handleResponderEnd = e => {
|
|
e = extractSingleTouch(e.nativeEvent);
|
|
if (e.touches) {
|
|
Recording.record('end;' + e.touches.length);
|
|
} else {
|
|
Recording.record('end;ExtraPointer');
|
|
}
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<View
|
|
style={styles.container}
|
|
onStartShouldSetResponder={this.handleStartShouldSetResponder}
|
|
onResponderMove={this.handleOnResponderMove}
|
|
onResponderStart={this.handleResponderStart}
|
|
onResponderEnd={this.handleResponderEnd}
|
|
collapsable={false}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
},
|
|
});
|
|
|
|
module.exports = TouchTestApp;
|