Skip to content

Commit d2682d5

Browse files
committed
animation test for menu
1 parent 3ca1115 commit d2682d5

File tree

10 files changed

+723
-585
lines changed

10 files changed

+723
-585
lines changed

App.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
import { StatusBar } from 'expo-status-bar';
21
import { StyleSheet, Text, View } from 'react-native';
3-
import { OOBAssetRiveTest } from './OOBAssetRiveTest';
2+
import { RiveTest } from './RiveTest';
43

54
export default function App() {
65
return (
76
<View style={styles.container}>
8-
<OOBAssetRiveTest />
9-
<Text>Open up App.tsx to start working on your app!</Text>
10-
<StatusBar style="auto" />
7+
<RiveTest />
118
</View>
129
);
1310
}
1411

1512
const styles = StyleSheet.create({
1613
container: {
1714
flex: 1,
18-
backgroundColor: 'pink',
1915
alignItems: 'center',
2016
justifyContent: 'center',
2117
},

OOBAssetRiveTest.tsx

Lines changed: 0 additions & 98 deletions
This file was deleted.

RiveTest.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type React from "react";
2+
import { SafeAreaView, ScrollView, StyleSheet, Text } from 'react-native';
3+
import Rive, { Alignment, Fit, type RNRiveError } from 'rive-react-native';
4+
// @ts-ignore
5+
import resolveAssetSource from "react-native/Libraries/Image/resolveAssetSource";
6+
7+
8+
// detects if it is an http or file url
9+
const stringIsUrl = (uri: string) => {
10+
return uri.startsWith("http") || uri.startsWith("file");
11+
};
12+
13+
export const RiveTest = () => {
14+
15+
// this allows the rive asset to be loaded locally using require() in expo during development AND in production
16+
const source = require('./assets/main_menu.riv');
17+
const resolved = resolveAssetSource(source);
18+
const uriIsUrl = stringIsUrl(resolved.uri);
19+
20+
return (
21+
<SafeAreaView style={styles.safeAreaViewContainer}>
22+
<Rive
23+
autoplay={true}
24+
fit={Fit.FitWidth}
25+
alignment={Alignment.BottomCenter}
26+
style={styles.box}
27+
// stateMachineName="State Machine 1"
28+
// artboardName="Artboard"
29+
onError={(riveError: RNRiveError) => {
30+
console.log(riveError);
31+
}}
32+
resourceName={!uriIsUrl ? resolved.uri : undefined}
33+
url={uriIsUrl ? resolved.uri : undefined}
34+
/>
35+
</SafeAreaView>
36+
);
37+
};
38+
39+
const styles = StyleSheet.create({
40+
safeAreaViewContainer: {
41+
flex: 1,
42+
width: '100%',
43+
},
44+
box: {
45+
width: '100%',
46+
height: 500,
47+
marginVertical: 20,
48+
},
49+
});

assets/Inter-594377.ttf

-18.6 KB
Binary file not shown.

assets/main_menu.riv

8.77 KB
Binary file not shown.

assets/out_of_band.riv

-305 KB
Binary file not shown.
-4.95 KB
Binary file not shown.
-55.7 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"web": "expo start --web"
1010
},
1111
"dependencies": {
12-
"expo": "~52.0.30",
12+
"expo": "^52.0.43",
1313
"expo-dev-client": "~5.0.11",
1414
"expo-status-bar": "~2.0.1",
1515
"react": "18.3.1",
1616
"react-native": "0.76.6",
17-
"rive-react-native": "^8.4.0"
17+
"rive-react-native": "^9.2.0"
1818
},
1919
"devDependencies": {
2020
"@babel/core": "^7.25.2",

0 commit comments

Comments
 (0)