Skip to content

Commit 3c6bbaa

Browse files
authored
Merge pull request #35 from productbrew/rn-reanimated-2
Update React Native Reanimated v2.2.
2 parents 8ca0828 + 42e4207 commit 3c6bbaa

31 files changed

+6116
-12463
lines changed

example/.expo-shared/assets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
3+
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
4+
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
node_modules/**/*
2-
.expo/*
1+
node_modules/
2+
.expo/
3+
dist/
34
npm-debug.*
45
*.jks
56
*.p8
@@ -8,4 +9,6 @@ npm-debug.*
89
*.mobileprovision
910
*.orig.*
1011
web-build/
11-
web-report/
12+
13+
# macOS
14+
.DS_Store

example/App.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {StatusBar} from 'expo-status-bar';
2+
import React from 'react';
3+
import {StyleSheet, View, Button} from 'react-native';
4+
5+
import FlipCard, { FlipSide, RotateAxis } from 'react-native-flip';
6+
import Side from "./Side";
7+
8+
export default function App() {
9+
const [side, setSide] = React.useState<FlipSide>(FlipSide.FRONT)
10+
const [rotate, setRotate] = React.useState<RotateAxis>(RotateAxis.Y)
11+
12+
return (
13+
<View style={styles.container}>
14+
<Button
15+
title={`Flip the card. The side of the card is: ${side}`}
16+
onPress={() => {
17+
setSide((side: FlipSide) => (side === FlipSide.FRONT ? FlipSide.BACK : FlipSide.FRONT))
18+
}}
19+
/>
20+
21+
<Button
22+
title={`Change rotation. The card rotation is: ${rotate}`}
23+
onPress={() => {
24+
setRotate((rotation: RotateAxis) => (rotation === RotateAxis.X ? RotateAxis.Y : RotateAxis.Y))
25+
}}
26+
/>
27+
28+
<FlipCard
29+
side={side}
30+
rotate={rotate}
31+
style={styles.flipContainer}
32+
front={<Side title="FRONT" color="blue"/>}
33+
back={<Side title="BACK" color="green"/>}
34+
/>
35+
<StatusBar style="auto"/>
36+
</View>
37+
);
38+
}
39+
40+
const styles = StyleSheet.create({
41+
container: {
42+
flex: 1,
43+
backgroundColor: '#fff',
44+
alignItems: 'center',
45+
justifyContent: 'center',
46+
},
47+
flipContainer: {
48+
height: 300,
49+
width: 300,
50+
borderWidth: 1,
51+
borderColor: "red",
52+
},
53+
});

example/Side.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from "react"
2+
import {Text, View, StyleSheet} from "react-native"
3+
4+
type Props = {
5+
title: string
6+
color: string
7+
}
8+
9+
const CardSide = ({title, color}: Props) => {
10+
const [count, setCount] = React.useState(0)
11+
12+
React.useEffect(() => {
13+
setInterval(() => {
14+
setCount(count => count + Math.floor(Math.random() * 20))
15+
}, 1000)
16+
}, [])
17+
18+
return (
19+
<View style={[styles.container, {backgroundColor: color}]}>
20+
<Text style={styles.text}>{title}</Text>
21+
<Text style={styles.text}>{count}</Text>
22+
</View>
23+
)
24+
}
25+
26+
const styles = StyleSheet.create({
27+
container: {
28+
justifyContent: "center",
29+
width: 200,
30+
height: 200,
31+
borderRadius: 10,
32+
borderWidth: 1,
33+
borderColor: "gray",
34+
margin: 'auto',
35+
},
36+
text: {
37+
textAlign: "center",
38+
color: "#fff",
39+
fontSize: 20,
40+
},
41+
})
42+
43+
export default CardSide
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
{
22
"expo": {
3-
"name": "react-native-flip-example",
4-
"slug": "examples",
5-
"privacy": "public",
6-
"sdkVersion": "35.0.0",
7-
"platforms": [
8-
"ios",
9-
"android",
10-
"web"
11-
],
3+
"name": "example",
4+
"slug": "example",
125
"version": "1.0.0",
136
"orientation": "portrait",
147
"icon": "./assets/icon.png",
@@ -25,6 +18,15 @@
2518
],
2619
"ios": {
2720
"supportsTablet": true
21+
},
22+
"android": {
23+
"adaptiveIcon": {
24+
"foregroundImage": "./assets/adaptive-icon.png",
25+
"backgroundColor": "#FFFFFF"
26+
}
27+
},
28+
"web": {
29+
"favicon": "./assets/favicon.png"
2830
}
2931
}
30-
}
32+
}

example/assets/adaptive-icon.png

17.1 KB
Loading

example/assets/favicon.png

1.43 KB
Loading

example/assets/icon.png

21.9 KB
Loading

example/assets/splash.png

46.2 KB
Loading

example/babel.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const pak = require("../package.json");
2+
const path = require("path");
3+
module.exports = function(api) {
4+
api.cache(true);
5+
return {
6+
presets: ['babel-preset-expo'],
7+
plugins: [
8+
[
9+
'module-resolver',
10+
{
11+
extensions: ['.tsx', '.ts', '.js', '.json'],
12+
alias: {
13+
// For development, we want to alias the library to the source
14+
[pak.name]: path.join(__dirname, '..', pak.source),
15+
},
16+
},
17+
],
18+
'react-native-reanimated/plugin',
19+
],
20+
};
21+
};

0 commit comments

Comments
 (0)