2018-12-19 07:58:46 -08:00
|
|
|
// @flow
|
2019-02-04 20:41:45 -08:00
|
|
|
|
2019-01-23 21:03:13 -08:00
|
|
|
import React, { PureComponent } from 'react';
|
2019-02-15 06:18:00 -08:00
|
|
|
import styled, { withTheme } from 'styled-components';
|
2019-01-23 21:03:13 -08:00
|
|
|
import { Transition, animated } from 'react-spring';
|
2018-12-19 07:58:46 -08:00
|
|
|
|
2019-01-02 12:34:32 -08:00
|
|
|
import CircleProgressComponent from 'react-circle';
|
2018-12-19 07:58:46 -08:00
|
|
|
import { TextComponent } from './text';
|
|
|
|
|
2019-01-02 12:34:32 -08:00
|
|
|
import zcashLogo from '../assets/images/zcash-simple-icon.svg';
|
|
|
|
|
2018-12-19 07:58:46 -08:00
|
|
|
const Wrapper = styled.div`
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
display: flex;
|
2019-01-02 12:34:32 -08:00
|
|
|
flex-direction: column;
|
2018-12-19 07:58:46 -08:00
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2019-02-18 15:40:15 -08:00
|
|
|
background-color: ${props => props.theme.colors.loadingScreenBg};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const LoadingCard = styled.div`
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
background: #000000;
|
|
|
|
padding: 60px;
|
|
|
|
min-width: 300px;
|
|
|
|
min-height: 200px;
|
|
|
|
border-radius: 3px;
|
2019-01-02 12:34:32 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const CircleWrapper = styled.div`
|
|
|
|
width: 125px;
|
|
|
|
height: 125px;
|
|
|
|
position: relative;
|
|
|
|
margin-bottom: 25px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Logo = styled.img`
|
|
|
|
z-index: 10;
|
|
|
|
position: absolute;
|
|
|
|
width: 50px;
|
|
|
|
height: 50px;
|
|
|
|
top: calc(50% - 25px);
|
|
|
|
left: calc(50% - 25px);
|
2018-12-19 07:58:46 -08:00
|
|
|
`;
|
|
|
|
|
2019-02-18 15:40:15 -08:00
|
|
|
const LoadingText = styled(TextComponent)`
|
|
|
|
color: ${props => props.theme.colors.loadingScreenText};
|
|
|
|
`;
|
|
|
|
|
2019-01-23 21:03:13 -08:00
|
|
|
type Props = {
|
|
|
|
progress: number,
|
2019-02-15 06:18:00 -08:00
|
|
|
theme: AppTheme,
|
2019-02-13 07:44:14 -08:00
|
|
|
message: string,
|
2019-01-24 06:56:49 -08:00
|
|
|
};
|
2019-01-23 21:03:13 -08:00
|
|
|
|
|
|
|
type State = {
|
|
|
|
start: boolean,
|
2019-01-24 06:56:49 -08:00
|
|
|
};
|
2019-01-23 21:03:13 -08:00
|
|
|
|
|
|
|
const TIME_DELAY_ANIM = 100;
|
|
|
|
|
2019-02-18 18:30:45 -08:00
|
|
|
class Component extends PureComponent<Props, State> {
|
2019-02-18 17:56:40 -08:00
|
|
|
state = { start: false };
|
2019-01-23 21:03:13 -08:00
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setState(() => ({ start: true }));
|
|
|
|
}, TIME_DELAY_ANIM);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-02-13 07:44:14 -08:00
|
|
|
const { start } = this.state;
|
2019-02-18 05:55:25 -08:00
|
|
|
const { progress, message, theme } = this.props;
|
2019-01-23 21:03:13 -08:00
|
|
|
|
|
|
|
return (
|
2019-01-31 08:38:42 -08:00
|
|
|
<Wrapper data-testid='LoadingScreen'>
|
2019-01-23 21:03:13 -08:00
|
|
|
<Transition
|
|
|
|
native
|
|
|
|
items={start}
|
2019-01-25 13:57:12 -08:00
|
|
|
enter={[{ height: 'auto', opacity: 1 }]}
|
|
|
|
leave={{ height: 0, opacity: 0 }}
|
2019-01-23 21:03:13 -08:00
|
|
|
from={{
|
|
|
|
position: 'absolute',
|
|
|
|
overflow: 'hidden',
|
|
|
|
height: 0,
|
2019-01-25 13:57:12 -08:00
|
|
|
opacity: 0,
|
2019-01-23 21:03:13 -08:00
|
|
|
}}
|
|
|
|
>
|
2019-02-06 19:06:48 -08:00
|
|
|
{() => (props: Object) => (
|
2019-02-04 16:32:53 -08:00
|
|
|
<animated.div
|
2019-02-04 20:41:45 -08:00
|
|
|
id='loading-screen'
|
2019-02-04 16:32:53 -08:00
|
|
|
style={{
|
|
|
|
...props,
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
}}
|
|
|
|
>
|
2019-02-18 15:40:15 -08:00
|
|
|
<LoadingCard>
|
|
|
|
<CircleWrapper>
|
|
|
|
<Logo src={zcashLogo} alt='Zcash Logo' />
|
|
|
|
<CircleProgressComponent
|
|
|
|
progress={progress}
|
|
|
|
responsive
|
|
|
|
showPercentage={false}
|
2019-02-20 07:02:23 -08:00
|
|
|
progressColor={theme.colors.activeItem(this.props)}
|
|
|
|
bgColor={theme.colors.inactiveItem(this.props)}
|
2019-02-18 15:40:15 -08:00
|
|
|
/>
|
|
|
|
</CircleWrapper>
|
|
|
|
<LoadingText value={message} />
|
|
|
|
</LoadingCard>
|
2019-01-23 21:03:13 -08:00
|
|
|
</animated.div>
|
|
|
|
)}
|
|
|
|
</Transition>
|
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-02-15 06:18:00 -08:00
|
|
|
|
|
|
|
export const LoadingScreen = withTheme(Component);
|