This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Intro.tsx
114 lines (103 loc) · 2.85 KB
/
Intro.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import {
NavigationParams,
NavigationScreenProp,
NavigationState,
} from 'react-navigation';
import Button from '../shared/Button';
import { IC_MASK } from '../../utils/Icons';
import React from 'react';
import { User } from '../../types';
import { View } from 'react-native';
import { getString } from '../../../STRINGS';
import styled from 'styled-components/native';
import { useAppContext } from '../../providers/AppProvider';
import { useThemeContext } from '../../providers/ThemeProvider';
const Container = styled.View`
flex: 1;
align-self: stretch;
overflow: scroll;
background-color: ${({ theme }): string => theme.background};
flex-direction: column;
justify-content: flex-start;
align-items: center;
overflow: hidden;
`;
const ContentWrapper = styled.View`
flex-direction: column;
height: 100%;
width: 100%;
justify-content: flex-start;
align-items: center;
`;
const ButtonWrapper = styled.View`
position: absolute;
flex-direction: column;
bottom: 40;
width: 85%;
align-self: center;
`;
const StyledText = styled.Text`
font-size: 18;
line-height: 27;
color: ${({ theme }): string => theme.fontColor};
`;
interface Props {
navigation: NavigationScreenProp<NavigationState, NavigationParams>;
}
function Intro(props: Props): React.ReactElement {
let timer: number;
const { state, setUser } = useAppContext();
const { changeThemeType } = useThemeContext();
const [isLoggingIn, setIsLoggingIn] = React.useState<boolean>(false);
const onLogin = (): void => {
setIsLoggingIn(true);
timer = setTimeout(() => {
const user: User = {
displayName: 'dooboolab',
age: 30,
job: 'developer',
};
// dispatch({ type: 'set-user', payload: { user: user } });
setUser(user);
setIsLoggingIn(false);
clearTimeout(timer);
}, 1000);
};
return (
<Container>
<ContentWrapper>
<StyledText
style={{
marginTop: 100,
}}
>
{state.user ? state.user.displayName : ''}
</StyledText>
<StyledText>{state.user ? state.user.age : ''}</StyledText>
<StyledText>{state.user ? state.user.job : ''}</StyledText>
</ContentWrapper>
<ButtonWrapper>
<Button
testID='btn1'
imgLeftSrc={IC_MASK}
isLoading={isLoggingIn}
onClick={(): void => onLogin()}
text={getString('LOGIN')}
/>
<View style={{ marginTop: 8 }} />
<Button
testID='btn2'
onClick={(): boolean => props.navigation.navigate('Temp')}
text={getString('NAVIGATE')}
/>
<View style={{ marginTop: 8 }} />
<Button
testID='btn3'
onClick={(): void => changeThemeType()}
text={getString('CHANGE_THEME')}
/>
</ButtonWrapper>
</Container>
);
}
export default Intro;