diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..27955d6 --- /dev/null +++ b/.vscode/launch.json @@ -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 + } + ] +} \ No newline at end of file diff --git a/App.js b/App.js index 52fa98e..0af2a54 100644 --- a/App.js +++ b/App.js @@ -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() { diff --git a/Views/Feed.js b/Views/Feed.js index 388d981..9365e3f 100644 --- a/Views/Feed.js +++ b/Views/Feed.js @@ -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 }) } diff --git a/app.json b/app.json index 177fe1d..c59ee69 100644 --- a/app.json +++ b/app.json @@ -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", diff --git a/components/Login.js b/components/Login.js index 6d283b4..3ed939e 100644 --- a/components/Login.js +++ b/components/Login.js @@ -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 ( - Login + EMI Social + Login setEmail(text)} @@ -42,9 +52,9 @@ let LoginForm = () => { mode="outlined" /> @@ -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, + } }); \ No newline at end of file