Login Ready, changing app name

This commit is contained in:
Adolfo Reyna
2022-11-11 13:41:32 -05:00
parent 7bc7069486
commit 46435bc440
5 changed files with 72 additions and 11 deletions

41
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,41 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "android"
},
{
"name": "Debug iOS",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "ios"
},
{
"name": "Debug Direct iOS - Experimental",
"cwd": "${workspaceFolder}",
"type": "reactnativedirect",
"request": "launch",
"platform": "ios",
"useHermesEngine": false,
"target": "device",
"port": 9221
},
{
"name": "Attach to Direct iOS - Experimental",
"cwd": "${workspaceFolder}",
"type": "reactnativedirect",
"request": "attach",
"platform": "ios",
"useHermesEngine": false,
"port": 9221
}
]
}

5
App.js
View File

@@ -82,7 +82,8 @@ const MainNavigation = () => {
useEffect(() => { useEffect(() => {
registerForPushNotificationsAsync().then(async (token) => { registerForPushNotificationsAsync().then(async (token) => {
let isLoggedIn = await API.isLoggedIn(); let isLoggedIn = await API.isLoggedIn();
if (isLoggedIn) API.registerToken(token); if (!isLoggedIn) return false;
API.registerToken(token);
return setExpoPushToken(token); return setExpoPushToken(token);
}); });
@@ -195,7 +196,7 @@ export default function App() {
<NavigationContainer> <NavigationContainer>
<Stack.Navigator> <Stack.Navigator>
<Stack.Screen <Stack.Screen
name="EMI Social" name="MainNavigation"
component={MainNavigation} component={MainNavigation}
options={{ headerShown: true }} options={{ headerShown: true }}
/> />

View File

@@ -33,7 +33,10 @@ let Feed = ({ navigation, route }) => {
console.log("Render Feed"); console.log("Render Feed");
useEffect(async () => { useEffect(async () => {
let loggedIn = await API.isLoggedIn(); let loggedIn = await API.isLoggedIn();
if(!loggedIn) return navigation.navigate('Login'); if(!loggedIn) return navigation.reset({
index: 0,
routes: [{ name: 'Login' }],
});
if (route.params && route.params.profileid) { if (route.params && route.params.profileid) {
navigation.navigate('Profile', { profileid: route.params.profileid }) navigation.navigate('Profile', { profileid: route.params.profileid })
} }

View File

@@ -1,7 +1,7 @@
{ {
"expo": { "expo": {
"name": "app", "name": "EMI Social",
"slug": "app", "slug": "emi-social",
"version": "1.0.0", "version": "1.0.0",
"orientation": "portrait", "orientation": "portrait",
"icon": "./assets/icon.png", "icon": "./assets/icon.png",

View File

@@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar'; import { StatusBar } from 'expo-status-bar';
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { Text, View, StyleSheet, Image } from 'react-native'; import { Text, View, StyleSheet, Image } from 'react-native';
import { TextInput, Button } from 'react-native-paper'; import { TextInput, Button } from 'react-native-paper';
import API from './../API.js'; import API from './../API.js';
@@ -12,13 +12,23 @@ let LoginForm = () => {
let [password, setPassword] = useState(''); let [password, setPassword] = useState('');
const navigation = useNavigation(); const navigation = useNavigation();
const loginCall = async ()=>{
let r = await API.logIn(email, password);
if (r.status === "ok") return navigation.reset({
index: 0,
routes: [{ name: 'MainNavigation' }],
});
alert('Please review the information')
};
return ( return (
<View style={styles.mainView}> <View style={styles.mainView}>
<Image <Image
style={styles.logo} style={styles.logo}
source={require('./../assets/icon.png')} source={require('./../assets/icon.png')}
/> />
<Text style={styles.header}>Login</Text> <Text style={styles.header}>EMI Social</Text>
<Text >Login</Text>
<TextInput <TextInput
style={styles.input} style={styles.input}
onChangeText={text => setEmail(text)} onChangeText={text => setEmail(text)}
@@ -42,9 +52,9 @@ let LoginForm = () => {
mode="outlined" mode="outlined"
/> />
<Button <Button
style={styles.button}
onPress={async () => { onPress={async () => {
let r = await API.logIn(email, password); await loginCall();
if (r.status === "ok") navigation.navigate('Feed');
}} }}
>submit</Button> >submit</Button>
</View> </View>
@@ -61,7 +71,8 @@ const styles = StyleSheet.create({
justifyContent: "flex-start", justifyContent: "flex-start",
padding: 15, padding: 15,
width: "100%", width: "100%",
alignContent: 'center' alignContent: 'center',
alignItems: 'center',
}, },
header: { header: {
fontFamily: 'Helvetica-Bold', fontFamily: 'Helvetica-Bold',
@@ -78,6 +89,11 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
}, },
input:{ input:{
backgroundColor: 'white' backgroundColor: 'white',
width: "80%"
},
button:{
marginTop: 10,
} }
}); });