-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
75 lines (68 loc) · 2.02 KB
/
App.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
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import { useState } from 'react';
import { useFonts } from 'expo-font';
import AppLoading from 'expo-app-loading';
import { HomeScreen } from './screens/HomeScreen';
import { WelcomeScreen } from './screens/WelcomeScreen';
import store from './store';
import { Provider } from 'react-redux';
import { init } from './db';
init()
.then(() => {
console.log('Database initialized');
})
.catch((err) => {
console.log('Database failed');
console.log(err.message);
});
export default function App() {
//Manejo de fuentes
const [loaded] = useFonts({
Montserrat: require('./assets/fonts/Montserrat-Regular.ttf'),
BebasNeue: require('./assets/fonts/BebasNeue-Regular.ttf'),
});
if (!loaded) {
<AppLoading />;
}
//Manejo cambio de pantallas al apretar en el boton SignIn
const [screen, setScreen] = useState(true);
const handleScreen = () => {
if (emailInput.length !== 0 && passwordInput.length !== 0) {
setScreen(true);
} else {
setInputError('Todos los campos son obligatorios');
}
};
//UseState para controlar formulario
const [emailInput, setEmailInput] = useState('');
const [passwordInput, setPasswordInput] = useState('');
const handleEmailForm = (t) => setEmailInput(t);
const handlePasswordForm = (t) => setPasswordInput(t);
//Estado para manejar input vacio
const [inputError, setInputError] = useState('');
useEffect(() => {}, []);
return (
<Provider store={store}>
<View style={styles.containerPrincipal}>
{screen ? (
<HomeScreen />
) : (
<WelcomeScreen
onpress={handleScreen}
onchangeEmail={handleEmailForm}
valueEmail={emailInput}
onchangePassword={handlePasswordForm}
valuePassword={passwordInput}
error={inputError}
/>
)}
</View>
</Provider>
);
}
const styles = StyleSheet.create({
containerPrincipal: {
flex: 1,
},
});