diff --git a/App.js b/App.js
index cbeaada..d22f18b 100644
--- a/App.js
+++ b/App.js
@@ -9,6 +9,7 @@ import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Login from "./Views/Login.js"
import Feed from "./Views/Feed.js"
+import Profile from "./Views/Profile.js"
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
const Tab = createMaterialBottomTabNavigator();
@@ -38,7 +39,8 @@ export default function App() {
},
})}
/>
-
+
+
);
diff --git a/Store.js b/Store.js
new file mode 100644
index 0000000..9bda2e7
--- /dev/null
+++ b/Store.js
@@ -0,0 +1,10 @@
+import { createStore } from 'easy-peasy';
+
+const store = createStore({
+ currentUser: ['Create store', 'Wrap application', 'Use store'],
+ addTodo: action((state, payload) => {
+ state.todos.push(payload);
+ }),
+});
+
+export default store;
\ No newline at end of file
diff --git a/Views/Feed.js b/Views/Feed.js
index eed0c6b..a5be5dc 100644
--- a/Views/Feed.js
+++ b/Views/Feed.js
@@ -1,10 +1,9 @@
import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect } from 'react';
-import { View, ScrollView, StyleSheet, SafeAreaView } from 'react-native';
+import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'react-native';
import API from './../API.js';
import Post from './../components/Post.js';
import { Provider as PaperProvider } from 'react-native-paper';
-import AwesomeIcon from 'react-native-vector-icons/FontAwesome';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import NewPost from "./../components/NewPost.js";
@@ -18,9 +17,7 @@ let Feed = ({ navigation, route }) => {
let r = await API.getMe();
setMeProfile(r);
if (route.params && route.params.profileid) {
- API.getPosts(route.params.profileid).then((data) => {
- setPosts(data);
- });
+ navigation.navigate('Profile', {profileid: route.params.profileid})
} else {
let posts = await API.getPosts();
setPosts(posts);
@@ -28,6 +25,10 @@ let Feed = ({ navigation, route }) => {
}
//console.log(posts)
}, [route.params]);
+ const renderPost = (({ item }) => {
+ return ();
+ });
+
return (
{
}}>
-
-
- {
- Posts.map((post, i) => {
- return (
- //{post.content}
-
- )
- })
- }
-
+ {Posts.length === 0 && }
+ item._id || item.createdAt}
+ ListHeaderComponent={ setPosts([newPost, ...Posts])} />}
+ />
diff --git a/Views/Profile.js b/Views/Profile.js
new file mode 100644
index 0000000..d6f71ae
--- /dev/null
+++ b/Views/Profile.js
@@ -0,0 +1,61 @@
+import { StatusBar } from 'expo-status-bar';
+import React, { useState, useEffect } from 'react';
+import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'react-native';
+import API from './../API.js';
+import Post from './../components/Post.js';
+import { Provider as PaperProvider } from 'react-native-paper';
+import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
+import NewPost from "./../components/NewPost.js";
+
+
+
+let Profile = ({ 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) {
+ API.getPosts(route.params.profileid).then((data) => {
+ setPosts(data);
+ });
+ } else {
+ navigation.navigate('Feed')
+ }
+ }, [route.params]);
+ const renderPost = (({ item }) => {
+ return ();
+ });
+
+ return (
+ ,
+ }}>
+
+
+ {Posts.length === 0 && }
+ {Posts.length !== 0 &&
+ item._id || item.createdAt}
+ ListHeaderComponent={ setPosts([newPost, ...Posts])} />}
+ />
+ }
+
+
+
+
+ );
+}
+
+export default Profile;
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ alignItems: 'center',
+ backgroundColor: "#edf2f7",
+ },
+});
diff --git a/components/Comment.js b/components/Comment.js
index d0c74de..8689304 100644
--- a/components/Comment.js
+++ b/components/Comment.js
@@ -14,7 +14,7 @@ let Comment = ({ comment }) => {
-
+
@@ -32,7 +32,7 @@ let Comment = ({ comment }) => {
);
}
-export default Comment;
+export default React.memo(Comment);
const styles = StyleSheet.create({
comment: {
diff --git a/components/NewPost.js b/components/NewPost.js
index aab21df..e341acb 100644
--- a/components/NewPost.js
+++ b/components/NewPost.js
@@ -5,7 +5,7 @@ import API from './../API.js';
import { useNavigation } from '@react-navigation/native';
-let NewPost = () => {
+let NewPost = ({profileid, newPostCB}) => {
let [postContent, setPostContent] = useState('');
const navigation = useNavigation();
@@ -23,9 +23,10 @@ let NewPost = () => {
diff --git a/components/Post.js b/components/Post.js
index e6f15fa..50de76c 100644
--- a/components/Post.js
+++ b/components/Post.js
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
-import { Text, View, ScrollView, StyleSheet } from 'react-native';
+import { Text, ScrollView, FlatList, StyleSheet } from 'react-native';
import { Avatar, Button, Card, Title, Paragraph } from 'react-native-paper';
import API from './../API.js';
import UserName from './UserName.js';
@@ -15,12 +15,15 @@ let Post = (props) => {
let toProfileText = post.toProfile && post.toProfile !== post.profileid ?
{">"} : undefined;
let cleanContent = post.content.replace(/@[A-z]+:.+\w/g, '');
- const newComentAdded = (commentData) => {
+ const newComentAdded = (commentData) => {
//add to comments
- props.post.comments.push(commentData);
- changePost(props.post);
- console.log(commentData);
+ let newPostObj = { ...post };
+ newPostObj.comments.push(commentData);
+ changePost(newPostObj);
};
+ const renderComment = ({ item }) => (
+
+ );
return (
@@ -28,30 +31,30 @@ let Post = (props) => {
{toProfileText}
- {cleanContent}
+ {cleanContent}
-
+
-
-
-
-
-
+
+
+
+
+
- {showCommentsB && }
- {
- showCommentsB &&
- (
- post.comments.map((comment, i) => {
- return
- })
- )
- }
+ {showCommentsB && }
+ {
+ showCommentsB && item.createdAt}
+ />
+ }
+
);
}
-export default Post;
+export default React.memo(Post);
const styles = StyleSheet.create({
userName: {
@@ -64,7 +67,7 @@ const styles = StyleSheet.create({
margin: 8,
backgroundColor: "#FFFFFF"
},
- comment:{
+ comment: {
margin: 8,
marginTop: 0,
padding: 8
diff --git a/components/UserName.js b/components/UserName.js
index c38f767..53a16d3 100644
--- a/components/UserName.js
+++ b/components/UserName.js
@@ -14,11 +14,11 @@ let UserName = (props) => {
}, [props.profileid]);
return (
- {navigation.navigate('Feed', {profileid: props.profileid})}} >{profile.profile && profile.profile.firstName} {profile.profile && profile.profile.lastName}
+ {navigation.navigate('Profile', {profileid: props.profileid})}} >{profile.profile && profile.profile.firstName} {profile.profile && profile.profile.lastName}
);
}
-export default UserName;
+export default React.memo(UserName);
const styles = StyleSheet.create({
});