Skip to content

Commit

Permalink
Add register screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
olifer97 committed May 7, 2020
1 parent ef034dd commit ec155c2
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/app/components/TabBarIcon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import React from 'react';

import { COLORS } from '@constants/colors';

import styles from './styles';

export default function TabBarIcon({ name, focused }) {
return (
<Ionicons
name={name}
size={30}
style={{ marginBottom: -3 }}
style={styles.icon}
color={focused ? COLORS.main : COLORS.gray}
/>
);
Expand Down
9 changes: 9 additions & 0 deletions src/app/components/TabBarIcon/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { StyleSheet } from 'react-native';

const styles = StyleSheet.create({
icon: {
marginBottom: -3
}
});

export default styles;
2 changes: 2 additions & 0 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { ROUTES } from '@constants/routes';
import { COLORS } from '@constants/colors';
import LoginScreen from '@screens/LoginScreen';
import SignUpScreen from '@screens/SignUpScreen';
import InitialLoading from '@screens/InitialLoading';
import HomeScreen from '@screens/HomeScreen';
import NotificationsScreen from '@screens/NotificationsScreen';
Expand Down Expand Up @@ -91,6 +92,7 @@ export default function App() {
<Stack.Navigator initialRouteName={ROUTES.Login} headerMode="none">
<Stack.Screen name={ROUTES.InitialLoading} component={InitialLoading} />
<Stack.Screen name={ROUTES.Login} component={LoginScreen} />
<Stack.Screen name={ROUTES.SignUp} component={SignUpScreen} />
<Stack.Screen name={ROUTES.Home} component={TabNavigatorScreen} />
</Stack.Navigator>
</NavigationContainer>
Expand Down
10 changes: 8 additions & 2 deletions src/app/screens/LoginScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { View, SafeAreaView, TextInput, Text } from 'react-native';
import CustomButton from '@components/CustomButton';
import { ROUTES } from '@constants/routes';

import { validateEmail } from './utils';
import { validateEmail } from '@utils/email';

import styles from './styles';

Expand All @@ -24,7 +24,7 @@ function LoginScreen({ navigation }) {

return (
<SafeAreaView style={styles.container}>
<Text style={styles.title}>TU2BO</Text>
<Text style={styles.title}>Tu2bo</Text>
<View styles={styles.loginContainer}>
<TextInput
style={styles.input}
Expand All @@ -49,6 +49,12 @@ function LoginScreen({ navigation }) {
onPress={onSubmit}
disable={disable}
/>
<CustomButton
text="UNIRSE"
style={styles.loginButton}
textStyle={styles.loginButtonText}
onPress={() => navigation.navigate(ROUTES.SignUp)}
/>
</View>
</SafeAreaView>
);
Expand Down
67 changes: 67 additions & 0 deletions src/app/screens/SignUpScreen/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useCallback, useState } from 'react';
import { View, SafeAreaView, TextInput, Text } from 'react-native';

import CustomButton from '@components/CustomButton';
import { ROUTES } from '@constants/routes';

import { validateEmail } from '@utils/email';

import styles from './styles';

function SignUpScreen({ navigation }) {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [confirmPw, setConfirmPw] = useState('');

const emailValid = validateEmail(email);
const passwordValid = password.length > 0;
const disable = !emailValid || !passwordValid || password !== confirmPw;

const onSubmit = useCallback(() => {
navigation.navigate(ROUTES.Login);
setEmail('');
setPassword('');
setConfirmPw('');
}, [navigation]);

return (
<SafeAreaView style={styles.container}>
<Text style={styles.title}>Tu2bo</Text>
<View styles={styles.loginContainer}>
<TextInput
style={styles.input}
onChangeText={setEmail}
value={email}
label="Email"
placeholder="Email"
keyboardType="email-address"
/>
<TextInput
style={styles.input}
onChangeText={setPassword}
value={password}
label="Password"
placeholder="Contraseña"
secureTextEntry
/>
<TextInput
style={styles.input}
onChangeText={setConfirmPw}
value={confirmPw}
label="Confirm Password"
placeholder="Confirmar Contraseña"
secureTextEntry
/>
<CustomButton
text="REGISTRARSE"
style={[styles.loginButton, disable && styles.buttonDisable]}
textStyle={disable ? styles.textDisable : styles.loginButtonText}
onPress={onSubmit}
disable={disable}
/>
</View>
</SafeAreaView>
);
}

export default SignUpScreen;
45 changes: 45 additions & 0 deletions src/app/screens/SignUpScreen/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { StyleSheet } from 'react-native';
import { COLORS } from '../../../constants/colors';

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: COLORS.main
},
title: {
fontSize: 40,
fontWeight: 'bold',
color: COLORS.white,
marginBottom: 30
},
loginContainer: {
flex: 1
},
input: {
backgroundColor: COLORS.white,
borderRadius: 5,
marginBottom: 20,
padding: 5,
width: 200
},
loginButton: {
backgroundColor: COLORS.main,
borderStyle: 'solid',
borderWidth: 1,
borderColor: COLORS.white,
marginBottom: 10
},
buttonDisable: {
borderColor: COLORS.gray
},
loginButtonText: {
color: COLORS.white
},
textDisable: {
color: COLORS.gray
}
});

export default styles;
3 changes: 2 additions & 1 deletion src/constants/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export const ROUTES = {
Wall: 'Muro',
VideoScreen: 'VideoScreen',
Notifications: 'Notificaciones',
Profile: 'Perfil'
Profile: 'Perfil',
SignUp: 'Registro'
};
File renamed without changes.

0 comments on commit ec155c2

Please sign in to comment.