-
-
Notifications
You must be signed in to change notification settings - Fork 260
/
AnimatedBootSplash.tsx
61 lines (50 loc) · 1.67 KB
/
AnimatedBootSplash.tsx
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
56
57
58
59
60
61
import { useState } from "react";
import { Animated, Dimensions, Platform } from "react-native";
import BootSplash from "react-native-bootsplash";
const useNativeDriver = Platform.OS !== "web";
type Props = {
onAnimationEnd: () => void;
};
export const AnimatedBootSplash = ({ onAnimationEnd }: Props) => {
const [opacity] = useState(() => new Animated.Value(1));
const [translateY] = useState(() => new Animated.Value(0));
const { container, logo /*, brand */ } = BootSplash.useHideAnimation({
manifest: require("../assets/bootsplash/manifest.json"),
logo: require("../assets/bootsplash/logo.png"),
// darkLogo: require("../assets/bootsplash/dark-logo.png"),
// brand: require("../assets/bootsplash/brand.png"),
// darkBrand: require("../assets/bootsplash/dark-brand.png"),
// statusBarTranslucent: true,
// navigationBarTranslucent: true,
animate: () => {
const { height } = Dimensions.get("window");
Animated.stagger(250, [
Animated.spring(translateY, {
useNativeDriver,
toValue: -50,
}),
Animated.spring(translateY, {
useNativeDriver,
toValue: height,
}),
]).start();
Animated.timing(opacity, {
useNativeDriver,
toValue: 0,
duration: 150,
delay: 350,
}).start(() => {
onAnimationEnd();
});
},
});
return (
<Animated.View {...container} style={[container.style, { opacity }]}>
<Animated.Image
{...logo}
style={[logo.style, { transform: [{ translateY }] }]}
/>
{/* <Animated.Image {...brand} style={[brand.style, { opacity }]} /> */}
</Animated.View>
);
};