2020-06-20 16:18:43 +02:00
|
|
|
import React, { useEffect, useState, useRef } from 'react';
|
2020-06-20 06:18:17 +02:00
|
|
|
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);
|
|
|
|
};
|
2020-06-20 16:06:36 +02:00
|
|
|
const walletMigrate = useRef(new WalletMigrate(handleMigrationComplete));
|
2020-06-20 06:18:17 +02:00
|
|
|
|
|
|
|
const replaceStackNavigation = () => {
|
|
|
|
NavigationService.dispatch(StackActions.replace('UnlockWithScreenRoot'));
|
|
|
|
};
|
|
|
|
|
|
|
|
const onAnimationFinish = () => {
|
|
|
|
if (isMigratingData) {
|
|
|
|
loadingAnimation.current.play(0);
|
|
|
|
} else {
|
|
|
|
replaceStackNavigation();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-20 16:18:43 +02:00
|
|
|
useEffect(() => {
|
|
|
|
walletMigrate.current.start();
|
|
|
|
}, [walletMigrate]);
|
|
|
|
|
2020-06-20 06:18:17 +02:00
|
|
|
return (
|
|
|
|
<LottieView
|
|
|
|
ref={loadingAnimation}
|
|
|
|
source={require('./img/bluewalletsplash.json')}
|
|
|
|
autoPlay
|
|
|
|
loop={false}
|
|
|
|
onAnimationFinish={onAnimationFinish}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
export default LoadingScreen;
|