diff --git a/example/src/pages/EventsDetailView.tsx b/example/src/pages/EventsDetailView.tsx new file mode 100644 index 00000000..5c85b85c --- /dev/null +++ b/example/src/pages/EventsDetailView.tsx @@ -0,0 +1,90 @@ +import { View, Text, StyleSheet, ActivityIndicator } from 'react-native'; +import { Fit, RiveView, useRive, useRiveFile } from 'react-native-rive'; +import { type Metadata } from '../helpers/metadata'; + +/** + * A secondary view with a Rive animation + */ +export default function EventsDetailView() { + const { setHybridRef } = useRive(); + const { riveFile, isLoading, error } = useRiveFile( + require('../../assets/rive/rewards.riv') + ); + + return ( + + Detail View + + This is a separate view with a different Rive animation + + + {isLoading ? ( + + ) : error ? ( + {error} + ) : riveFile ? ( + + ) : null} + + + Press the back button to return to the Events example + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#fff', + padding: 20, + }, + title: { + fontSize: 24, + fontWeight: 'bold', + textAlign: 'center', + marginTop: 20, + marginBottom: 10, + }, + subtitle: { + fontSize: 16, + color: '#666', + textAlign: 'center', + marginBottom: 20, + }, + riveContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + backgroundColor: '#f5f5f5', + borderRadius: 10, + overflow: 'hidden', + }, + rive: { + width: '100%', + height: '100%', + }, + errorText: { + color: 'red', + textAlign: 'center', + padding: 20, + }, + instructions: { + fontSize: 14, + color: '#999', + textAlign: 'center', + marginTop: 20, + fontStyle: 'italic', + }, +}); + +EventsDetailView.metadata = { + name: 'Events Detail', + description: 'A secondary view with a Rive animation', +} satisfies Metadata; diff --git a/example/src/pages/RiveEventsExample.tsx b/example/src/pages/RiveEventsExample.tsx index 486a6df7..5e43f8a9 100644 --- a/example/src/pages/RiveEventsExample.tsx +++ b/example/src/pages/RiveEventsExample.tsx @@ -1,4 +1,10 @@ -import { View, Text, StyleSheet, ActivityIndicator } from 'react-native'; +import { + View, + Text, + StyleSheet, + ActivityIndicator, + TouchableOpacity, +} from 'react-native'; import { useState, useEffect } from 'react'; import { Fit, @@ -17,7 +23,7 @@ import { type Metadata } from '../helpers/metadata'; * * Demonstrates getting and handling Rive events */ -export default function EventsExample() { +export default function EventsExample({ navigation }: { navigation: any }) { const { riveViewRef, setHybridRef } = useRive(); const { riveFile, isLoading, error } = useRiveFile( require('../../assets/rive/rating.riv') @@ -60,6 +66,14 @@ export default function EventsExample() { /> ) : null} + navigation.navigate('EventsDetailView')} + > + + Go to Detail View with Another Rive Animation + + {lastEvent && ( Last Event: @@ -146,6 +160,19 @@ const styles = StyleSheet.create({ marginTop: 10, marginBottom: 5, }, + navigateButton: { + backgroundColor: '#007AFF', + padding: 15, + borderRadius: 10, + marginTop: 15, + marginBottom: 10, + }, + navigateButtonText: { + color: '#fff', + fontSize: 16, + fontWeight: 'bold', + textAlign: 'center', + }, }); EventsExample.metadata = {