-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.js
114 lines (103 loc) · 3.72 KB
/
Main.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
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
// React Native component that renders a user interface for a login and account creation page.
// It has two child components, CreateAccount and LogIn, which are switched between by using useState()
// hooks to keep track of the currently active component and updating the state when a user selects one of the buttons.
import { StatusBar } from 'expo-status-bar';
import { Image, View, StyleSheet, Text, TouchableOpacity } from 'react-native';
import React, {Component, useState} from "react";
import CreateAccount from "./CreateAccount";
import LogIn from './LogIn';
export default function Main() {
const [currentComponent, setSelector] = useState(<CreateAccount/>);
const [createAccountText, setCreateAccountText] = useState(styles.activeText);
const [createAccount, setCreateAccount] = useState(styles.selectorActive);
const [logInText, setLogInText] = useState(styles.inactiveText);
const [logIn, setLogIn] = useState(styles.selectorInactive);
return (
<View style={styles.container}>
<View style={styles.upperView}>
<Image style={styles.pattern} source={require('./img/Pattern.png')} />
<Image style={styles.illustration} source={require('./img/Illustration.png')} />
</View>
<View style={styles.lowerView}>
<View style={styles.selectorContainer}>
<TouchableOpacity
style={[styles.selectorButton, createAccount]}
onPress={() => {
setSelector(<CreateAccount />);
setCreateAccount(styles.selectorActive);
setCreateAccountText(styles.activeText);
setLogIn(styles.selectorInactive);
setLogInText(styles.inactiveText);
}}>
<Text style={createAccountText}>Create Account</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.selectorButton, logIn]}
onPress={() => {
setSelector(<LogIn />);
setLogIn(styles.selectorActive);
setLogInText(styles.activeText);
setCreateAccount(styles.selectorInactive);
setCreateAccountText(styles.inactiveText);
}}>
<Text style={logInText}>Log In</Text>
</TouchableOpacity>
</View>
{currentComponent}
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5F5F5',
alignItems: 'center',
justifyContent: 'center',
height: "100%",
width: "100%",
},
upperView: {
height: "30%",
width: "100%",
flex: 1,
flexDirection: 'column',
},
lowerView: {
height: "70%",
width: "100%",
flex: 2,
backgroundColor: "#F5F5F5"
},
selectorContainer: {
flexDirection: "row",
},
selectorButton: {
marginTop: "12.5%",
marginLeft: 40,
marginRight: 40,
borderBottomWidth: 1,
},
selectorActive: {
borderBottomColor: "#FF0000"
},
selectorInactive: {
borderBottomColor: "#999999"
},
activeText: {
fontSize: 20,
color: "#FF0000",
paddingBottom: 5
},
inactiveText: {
fontSize: 20,
color: "#999999",
paddingBottom: 5
},
pattern: {
},
illustration: {
position: "absolute",
marginTop: "12.5%"
}
});