diff --git a/API.js b/API.js index ed56bf1..542c06c 100644 --- a/API.js +++ b/API.js @@ -129,6 +129,9 @@ const API = { if (userid) return getCall("/post/usr/" + userid); return getCall("/post/"); }, + getPost(postid) { + return getCall("/post/" + postid); + }, deletePost(postid){ return deleteCall("/post/" + postid); }, diff --git a/App.js b/App.js index b522198..abfa63e 100644 --- a/App.js +++ b/App.js @@ -8,6 +8,8 @@ import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; import Login from "./Views/Login.js" import Feed from "./Views/Feed.js" import Profile from "./Views/Profile.js" +import Notifications from './Views/Notifications.js'; +import SinglePost from './Views/SinglePost.js' const Tab = createMaterialBottomTabNavigator(); @@ -45,7 +47,18 @@ const MainNavigation = () => { }, })} /> - + ( + + ), + tabBarBadge: false + }} + /> + ) @@ -70,6 +83,7 @@ export default function App() { tabBarLabel: 'Profile' }} /> + diff --git a/Views/Feed.js b/Views/Feed.js index 78cbe74..360c912 100644 --- a/Views/Feed.js +++ b/Views/Feed.js @@ -11,7 +11,6 @@ let Feed = ({ navigation, route }) => { let [Me, setMeProfile] = useState({}); let [Posts, setPosts] = useState([]); useEffect(async () => { - setPosts([]); let r = await API.getMe(); setMeProfile(r); if (route.params && route.params.profileid) { @@ -55,7 +54,6 @@ export default Feed; const styles = StyleSheet.create({ container: { flex: 1, - alignItems: 'center', backgroundColor: "#edf2f7", }, }); diff --git a/Views/Notifications.js b/Views/Notifications.js new file mode 100644 index 0000000..ffe5c46 --- /dev/null +++ b/Views/Notifications.js @@ -0,0 +1,61 @@ +import { StatusBar } from 'expo-status-bar'; +import React, { useState, useEffect } from 'react'; +import { View, Text, StyleSheet, SafeAreaView, FlatList } from 'react-native'; +import { Card } from 'react-native-paper'; +import API from './../API.js'; +import Post from './../components/Post.js'; + + +let LoadPost = ({ postid, viewer }) => { + let [post, setPost] = useState({}); + useEffect(async () => { + setPost(await API.getPost(postid)); + }, [postid]); + return (post._id ? : null); +}; + +let Notifications = ({ navigation, route }) => { + let [Me, setMeProfile] = useState({}); + let [notifications, setNotifications] = useState([]); + useEffect(async () => { + let r = await API.getMe(); + setMeProfile(r); + setNotifications(r.notifications) + }, [route.params]); + const renderNotification = (({ item }) => { + //return (); + const gotToPost = ()=>{ + navigation.navigate('SinglePost', {postid: item.postid, viewer: Me}); + }; + return ( + + + {item.body} + + + ) + }); + + + return ( + + + item.ts} + /> + + + + ); +} + +export default Notifications; + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: "#edf2f7", + }, +}); diff --git a/Views/Profile.js b/Views/Profile.js index c2cca24..d361296 100644 --- a/Views/Profile.js +++ b/Views/Profile.js @@ -17,6 +17,9 @@ let Profile = ({ navigation, route }) => { let r = await API.getMe(); setMeProfile(r); if (route.params && route.params.profileid) { + API.getUserProfile(route.params.profileid).then(({profile}) => { + navigation.setOptions({ title: profile.firstName + " " + profile.lastName }); + }); API.getPosts(route.params.profileid).then((data) => { setPosts(data); }); diff --git a/Views/SinglePost.js b/Views/SinglePost.js new file mode 100644 index 0000000..21bc517 --- /dev/null +++ b/Views/SinglePost.js @@ -0,0 +1,29 @@ +import { StatusBar } from 'expo-status-bar'; +import React, { useState, useEffect } from 'react'; +import { View, Text, StyleSheet, ScrollView, FlatList } from 'react-native'; +import API from './../API.js'; +import Post from './../components/Post.js'; + +let SinglePost = ({ route }) => { + let [post, setPost] = useState({}); + console.log(route.params.postid) + useEffect(async () => { + if (route.params.postid) + setPost(await API.getPost(route.params.postid)); + }, [route]); + return (post._id ? ( + + + + ) : null); +}; + +export default SinglePost; + +const styles = StyleSheet.create({ + container: { + flex: 1, + alignItems: 'center', + backgroundColor: "#edf2f7", + }, +});