Skip to content

Commit 207c7f2

Browse files
authored
Add LottieAnimation component (#933)
* add lottie animation component * clean up * add comment * update version * update lottie dependencies * clean up * adjust comment * support speed prop
1 parent 1917858 commit 207c7f2

File tree

8 files changed

+10964
-4
lines changed

8 files changed

+10964
-4
lines changed

example/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ import KeyboardAvoidingViewExample from "./KeyboardAvoidingViewExample";
7575
import ThemeExample from "./ThemeExample";
7676
import LoadingIndicatorExample from "./LoadingIndicatorExample";
7777
import TimerExample from "./TimerExample";
78+
import LottieAnimationExample from "./LottieAnimationExample";
7879

7980
const ROUTES = {
81+
LottieAnimationExample: LottieAnimationExample,
8082
Timer: TimerExample,
8183
LoadingIndicator: LoadingIndicatorExample,
8284
Theme: ThemeExample,
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import * as React from "react";
2+
import { View, StyleSheet, Text } from "react-native";
3+
import { LottieAnimation, withTheme } from "@draftbit/ui";
4+
import Section, { Container } from "./Section";
5+
6+
interface WrapperProps {
7+
label: string;
8+
children: React.ReactNode;
9+
}
10+
11+
const Wrapper: React.FC<WrapperProps> = ({ label, children }) => {
12+
return (
13+
<View style={styles.wrapper}>
14+
<View style={styles.boxLabel}>
15+
<Text>{label}</Text>
16+
</View>
17+
<View>{children}</View>
18+
</View>
19+
);
20+
};
21+
const LottieAnimationExample: React.FC = () => {
22+
return (
23+
<Container style={{}}>
24+
<Section style={{}} title="Lottie Animation">
25+
<View style={{ flexDirection: "row" }}>
26+
<Wrapper label="Default with uri">
27+
<LottieAnimation
28+
source={{
29+
uri: "https://lottie.host/55656a16-1441-43d6-a052-57b8e02d5c8f/SM1VujecK4.json",
30+
}}
31+
style={{
32+
width: 200,
33+
height: 200,
34+
}}
35+
/>
36+
</Wrapper>
37+
<Wrapper label="Static json data">
38+
<LottieAnimation
39+
source={require("./assets/lottie_animation_example.json")}
40+
style={{
41+
width: 200,
42+
height: 200,
43+
}}
44+
/>
45+
</Wrapper>
46+
</View>
47+
<View style={{ flexDirection: "row" }}>
48+
<Wrapper label="Resize and Styling">
49+
<LottieAnimation
50+
source={require("./assets/lottie_animation_example.json")}
51+
style={{
52+
width: 350,
53+
height: 350,
54+
backgroundColor: "black",
55+
}}
56+
/>
57+
</Wrapper>
58+
</View>
59+
<View style={{ flexDirection: "row" }}>
60+
<Wrapper label="No loop">
61+
<LottieAnimation
62+
source={require("./assets/lottie_animation_example.json")}
63+
loop={false}
64+
style={{
65+
width: 200,
66+
height: 200,
67+
}}
68+
/>
69+
</Wrapper>
70+
<Wrapper label="No autoplay">
71+
<LottieAnimation
72+
source={require("./assets/lottie_animation_example.json")}
73+
autoPlay={false}
74+
style={{
75+
width: 200,
76+
height: 200,
77+
}}
78+
/>
79+
</Wrapper>
80+
</View>
81+
</Section>
82+
</Container>
83+
);
84+
};
85+
86+
const styles = StyleSheet.create({
87+
wrapper: {
88+
flex: 1,
89+
display: "flex",
90+
flexDirection: "column",
91+
flexWrap: "wrap",
92+
justifyContent: "center",
93+
alignItems: "center",
94+
},
95+
boxLabel: {
96+
margin: 10,
97+
flex: 1,
98+
},
99+
});
100+
101+
export default withTheme(LottieAnimationExample);

0 commit comments

Comments
 (0)