forked from mcu0054/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LoadingScreen.js
42 lines (36 loc) · 1.14 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
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';
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 (
<LottieView
ref={loadingAnimation}
source={require('./img/bluewalletsplash.json')}
autoPlay
loop={false}
onAnimationFinish={onAnimationFinish}
/>
);
};
export default LoadingScreen;