1 |
|
2 |
|
3 | import { NativeModules } from 'react-native';
|
4 |
|
5 | import DeviceSensor from './DeviceSensor';
|
6 |
|
7 | const { ExponentDeviceMotion } = NativeModules;
|
8 |
|
9 | type Measurement = {
|
10 | acceleration: {
|
11 | x: number,
|
12 | y: number,
|
13 | z: number,
|
14 | },
|
15 | accelerationIncludingGravity: {
|
16 | x: number,
|
17 | y: number,
|
18 | z: number,
|
19 | },
|
20 | rotation: {
|
21 | alpha: number,
|
22 | beta: number,
|
23 | gamma: number,
|
24 | },
|
25 | rotationRate: {
|
26 | alpha: number,
|
27 | beta: number,
|
28 | gamma: number,
|
29 | },
|
30 | orientation: number,
|
31 | };
|
32 |
|
33 | class DeviceMotionSensor extends DeviceSensor<Measurement> {
|
34 | Gravity = ExponentDeviceMotion.Gravity;
|
35 | }
|
36 |
|
37 | export const Gravity = ExponentDeviceMotion.Gravity;
|
38 |
|
39 | export default new DeviceMotionSensor(
|
40 | ExponentDeviceMotion,
|
41 | 'deviceMotionDidUpdate'
|
42 | );
|