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

View File

@@ -33,7 +33,10 @@ let Feed = ({ navigation, route }) => {
console.log("Render Feed");
useEffect(async () => {
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) {
navigation.navigate('Profile', { profileid: route.params.profileid })
}

View File

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

View File

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