11import { useState } from 'react' ;
2- import { View , Text , StyleSheet , Button } from 'react-native' ;
2+ import { View , Text , StyleSheet , Button , ActivityIndicator } from 'react-native' ;
33import { SafeAreaView } from 'react-native-safe-area-context' ;
44import { Fit , RiveView , useRiveFile } from '@rive-app/react-native' ;
55import { type Metadata } from '../helpers/metadata' ;
66
77export default function ResponsiveLayoutsExample ( ) {
8- const { riveFile } = useRiveFile (
8+ const { riveFile, isLoading , error } = useRiveFile (
99 require ( '../../assets/rive/layouts_demo.riv' )
1010 ) ;
1111 const [ scaleFactor , setScaleFactor ] = useState ( 4.0 ) ;
@@ -16,15 +16,19 @@ export default function ResponsiveLayoutsExample() {
1616
1717 return (
1818 < SafeAreaView style = { styles . container } >
19- { riveFile && (
19+ { isLoading ? (
20+ < ActivityIndicator size = "large" style = { styles . rive } />
21+ ) : error ? (
22+ < Text style = { styles . errorText } > { error } </ Text >
23+ ) : riveFile ? (
2024 < RiveView
2125 file = { riveFile }
2226 fit = { Fit . Layout }
2327 layoutScaleFactor = { scaleFactor }
2428 style = { styles . rive }
2529 autoPlay = { true }
2630 />
27- ) }
31+ ) : null }
2832 < View style = { styles . controls } >
2933 < Text style = { styles . label } > Layout Scale Factor</ Text >
3034 < View style = { styles . scaleControls } >
@@ -71,4 +75,10 @@ const styles = StyleSheet.create({
7175 fontWeight : '500' ,
7276 marginTop : 16 ,
7377 } ,
78+ errorText : {
79+ color : 'red' ,
80+ textAlign : 'center' ,
81+ padding : 20 ,
82+ flex : 1 ,
83+ } ,
7484} ) ;
0 commit comments