-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathResponsiveLayouts.tsx
More file actions
55 lines (51 loc) · 1.45 KB
/
ResponsiveLayouts.tsx
File metadata and controls
55 lines (51 loc) · 1.45 KB
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
import { View, Text, StyleSheet, ActivityIndicator } from 'react-native';
import { Fit, RiveView, useRiveFile } from 'react-native-rive';
import { type Metadata } from '../helpers/metadata';
/**
* Demonstrates responsive layouts using Fit.Layout and layoutScaleFactor
*
* See https://rive.app/docs/runtimes/layout
*/
export default function ResponsiveLayoutsExample() {
const { riveFile, isLoading, error } = useRiveFile(
require('../../assets/rive/layouts_demo.riv')
);
return (
<View style={styles.container}>
{isLoading ? (
<ActivityIndicator size="large" color="#0000ff" />
) : error ? (
<Text style={styles.errorText}>{error}</Text>
) : riveFile ? (
<RiveView
file={riveFile}
fit={Fit.Layout}
layoutScaleFactor={1} // adjust the layout scale factor to control the layout scale
style={styles.rive}
/>
) : null}
</View>
);
}
const styles = StyleSheet.create({
// Adjust the container size and the layout will adjust based on the .riv file layout rules
container: {
width: '100%',
height: '100%',
},
rive: {
justifyContent: 'center',
alignItems: 'center',
width: '100%',
height: '100%',
},
errorText: {
color: 'red',
textAlign: 'center',
padding: 20,
},
});
ResponsiveLayoutsExample.metadata = {
name: 'Responsive Layouts',
description: 'Sample .riv file with responsive layouts',
} satisfies Metadata;