-
Notifications
You must be signed in to change notification settings - Fork 16
/
App.js
69 lines (58 loc) · 1.68 KB
/
App.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React from 'react';
import { SafeAreaView, StyleSheet } from 'react-native';
import Animated, {
useAnimatedSensor,
useAnimatedStyle,
SensorType,
} from 'react-native-reanimated';
import { Image } from 'react-native';
import { BlurView } from 'expo-blur';
const BORDER_RADIUS = 20;
const INTENSITY = 30;
const CARD_WIDTH = 230;
const CARD_HEIGHT = 380;
export default function App() {
const animatedSensor = useAnimatedSensor(SensorType.ROTATION, {
interval: 0,
});
const style = useAnimatedStyle(() => {
const { pitch, yaw, qy } = animatedSensor.sensor.value;
let num = qy > 0 ? 30 : 50;
let yawValue =
qy > 0 ? num * 2.5 * Number(qy.toFixed(2)) : num * qy.toFixed(2);
let pitchValue = 26 * pitch.toFixed(2);
return {
transform: [{ translateX: yawValue }, { translateY: pitchValue }],
};
});
return (
<SafeAreaView style={styles.container}>
<Image style={styles.imageStyle} source={require('./assets/1290.png')} />
<BlurView intensity={INTENSITY} style={StyleSheet.absoluteFill} />
<Animated.View style={[styles.animatedViewStyle, style]}>
<Image style={{ flex: 1 }} source={require('./assets/1290.png')} />
</Animated.View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
imageStyle: {
width: CARD_WIDTH,
height: CARD_HEIGHT,
borderRadius: BORDER_RADIUS,
},
animatedViewStyle: {
width: CARD_WIDTH + 20,
height: CARD_HEIGHT + 20,
borderRadius: BORDER_RADIUS,
overflow: 'hidden',
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
},
});