forked from BlueWallet/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathLoadingScreen.js
67 lines (60 loc) · 1.75 KB
/
LoadingScreen.js
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
62
63
64
65
66
67
import React, { useEffect, useState, useRef } from 'react';
import LottieView from 'lottie-react-native';;;;;;;;;;
import WalletMigrate from './screen/wallets/walletMigrate';
import * as NavigationService from './NavigationService';
import { StackActions } from '@react-navigation/native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { ImageBackground, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
root: {
flex: 1,
backgroundColor: 'rgba(95, 88, 84, .18)',
},
splash: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
splashImage: {
width: 120,
height: 120,
},
});
const LoadingScreen = () => {
const [isMigratingData, setIsMigratinData] = useState(true);
const loadingAnimation = useRef();
const handleMigrationComplete = async () => {
setIsMigratinData(false);
};
const walletMigrate = useRef(new WalletMigrate(handleMigrationComplete));
const replaceStackNavigation = () => {
NavigationService.dispatch(StackActions.replace('UnlockWithScreenRoot'));
};
const onAnimationFinish = () => {
if (isMigratingData) {
loadingAnimation.current.play(0);
} else {
replaceStackNavigation();
}
};
useEffect(() => {
walletMigrate.current.start();
}, [walletMigrate]);
return (
<SafeAreaView style={styles.root}>
<ImageBackground
style={{flex: 1, marginTop: 20}}
source={require('./img/splash/splash.png')}
>
<LottieView
ref={loadingAnimation}
source={require('./img/bluewalletsplash.json')}
autoPlay
loop={false}
onAnimationFinish={onAnimationFinish}
/>
</ImageBackground>
</SafeAreaView>
);
};
export default LoadingScreen;