From 2d1a14ec0250856d70f815a438bc7c3dac1add88 Mon Sep 17 00:00:00 2001 From: androcpp Date: Mon, 7 Mar 2022 18:59:02 +0200 Subject: [PATCH] Profile Screen Navigation and Data Fetch/Send DONE --- App.js | 6 ++-- screens/Dashboard.js | 6 +++- screens/ProfileScreen.js | 63 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 screens/ProfileScreen.js diff --git a/App.js b/App.js index 144818b..24ba5b7 100644 --- a/App.js +++ b/App.js @@ -5,6 +5,7 @@ import { createStackNavigator } from '@react-navigation/stack'; import Login from './screens/Login'; import Register from './screens/Register'; import Dashboard from './screens/Dashboard'; +import ProfileScreen from './screens/ProfileScreen'; import { NavigationContainer } from '@react-navigation/native'; import { loginValidation } from "./utils/Validation"; import { AccessToken, LoginManager } from "react-native-fbsdk-next"; @@ -123,7 +124,7 @@ export default App = ({navigation}) => { console.log("Something went wrong obtaining access token"); return; } - const userFb = await axios.get(`https://graph.facebook.com/${data.userID}?fields=id,name,email,picture&access_token=${data.accessToken}`); + const userFb = await axios.get(`https://graph.facebook.com/${data.userID}?fields=id,name,email,picture.type(large)&access_token=${data.accessToken}`); const {name, email, picture} = userFb.data; const img = picture.data.url; @@ -227,7 +228,8 @@ export default App = ({navigation}) => { ): ( <> - + + )} diff --git a/screens/Dashboard.js b/screens/Dashboard.js index bd0e858..05dbbc1 100644 --- a/screens/Dashboard.js +++ b/screens/Dashboard.js @@ -4,7 +4,7 @@ import MusicPlayer from "../components/MusicPlayer"; import AsyncStorage from "@react-native-async-storage/async-storage"; import HelloMessage from "../components/HelloMessage"; -export default function Dashboard() { +export default function Dashboard({navigation}) { var user; const [email, setEmail] = useState('email'); const [id, setId] = useState('id'); @@ -44,6 +44,10 @@ export default function Dashboard() { {name} */} + { + navigation.navigate('ProfileScreen', {email: email, name: name, img: img})}}> + Profile + ) diff --git a/screens/ProfileScreen.js b/screens/ProfileScreen.js new file mode 100644 index 0000000..132129a --- /dev/null +++ b/screens/ProfileScreen.js @@ -0,0 +1,63 @@ +import React, { useEffect } from "react"; +import {View, Text, SafeAreaView, Image, StyleSheet, ScrollView} from "react-native"; +import { TouchableOpacity } from "react-native-gesture-handler"; +import Ionicons from "react-native-vector-icons/Ionicons"; + +export default function ProfileScreen({route, navigation}) { + + const {email, name, img} = route.params; + + return ( + + + + { + if(navigation.canGoBack()) { + navigation.goBack(); + } + }} > + + + + + + + + + + {name} + {email} + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor:'#fff', + }, + text: { + fontfamily:'HelveticaNeue', + color:'#52575D' + }, + image: { + flex: 1, + width: undefined, + height: undefined, + }, + titleBar: { + flexDirection: 'row', + justifyContent: 'space-between', + marginTop: 24, + marginHorizontal: 16 + }, + profileImage: { + width: 200, + height: 200, + borderRadius: 100, + overflow: "hidden" + } +}); \ No newline at end of file