Changin to material icons
This commit is contained in:
37
API.js
37
API.js
@@ -17,6 +17,23 @@ let getCall = async (path = "", params = {}) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let deleteCall = async (path = "", params = {}) => {
|
||||||
|
let queryParams = "?";
|
||||||
|
Object.keys(params).forEach(p => {
|
||||||
|
queryParams += p + "=" + params[p] + "&"
|
||||||
|
});
|
||||||
|
return fetch(baseUrl + path + queryParams, {
|
||||||
|
method: 'DELETE',
|
||||||
|
mode: 'cors',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
}).then(response => response.json()).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
let postCall = async (path, params) => {
|
let postCall = async (path, params) => {
|
||||||
return fetch(baseUrl + path, {
|
return fetch(baseUrl + path, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -112,9 +129,13 @@ const API = {
|
|||||||
if (userid) return getCall("/post/usr/" + userid);
|
if (userid) return getCall("/post/usr/" + userid);
|
||||||
return getCall("/post/");
|
return getCall("/post/");
|
||||||
},
|
},
|
||||||
newPost(content, toProfile) {
|
deletePost(postid){
|
||||||
|
return deleteCall("/post/" + postid);
|
||||||
|
},
|
||||||
|
newPost(content, toProfile, isNews) {
|
||||||
//Content is expected to be a string.
|
//Content is expected to be a string.
|
||||||
let params = { content };
|
let params = { content };
|
||||||
|
if(isNews) params.nonOrganicType = "News"
|
||||||
if (toProfile && CurrentUserId !== toProfile)
|
if (toProfile && CurrentUserId !== toProfile)
|
||||||
params.toProfile = toProfile;
|
params.toProfile = toProfile;
|
||||||
return postCall("/post/", params);
|
return postCall("/post/", params);
|
||||||
@@ -157,8 +178,8 @@ const API = {
|
|||||||
getMyProfile() {
|
getMyProfile() {
|
||||||
return getCall("/user/" + CurrentProfile);
|
return getCall("/user/" + CurrentProfile);
|
||||||
},
|
},
|
||||||
updateMyProfile(profile) {
|
updateMyProfile(profile, data) {
|
||||||
return postCall("/user/myProfile", profile);
|
return postCall("/user/myProfile", {profile, data});
|
||||||
},
|
},
|
||||||
searchProfiles(query){
|
searchProfiles(query){
|
||||||
return getCall("/user/search", query ? {query} : {}).then((data)=>{
|
return getCall("/user/search", query ? {query} : {}).then((data)=>{
|
||||||
@@ -180,6 +201,9 @@ const API = {
|
|||||||
getUserProfile(profileid, refresh=false) {
|
getUserProfile(profileid, refresh=false) {
|
||||||
return getProfileFromCache(profileid, refresh);
|
return getProfileFromCache(profileid, refresh);
|
||||||
},
|
},
|
||||||
|
deleteProfile(profileid){
|
||||||
|
return deleteCall("/user/" + profileid);
|
||||||
|
},
|
||||||
currentProfileId() {
|
currentProfileId() {
|
||||||
if (!CurrentProfile) this.isLoggedIn(); //replace with cookie
|
if (!CurrentProfile) this.isLoggedIn(); //replace with cookie
|
||||||
return CurrentProfile;
|
return CurrentProfile;
|
||||||
@@ -245,6 +269,13 @@ const API = {
|
|||||||
},
|
},
|
||||||
unsubscribeToGroup(groupid){
|
unsubscribeToGroup(groupid){
|
||||||
return getCall("/user/groups/" + groupid + "/unsubscribe");
|
return getCall("/user/groups/" + groupid + "/unsubscribe");
|
||||||
|
},
|
||||||
|
//Payments
|
||||||
|
paymentIntent(userid, price, description){
|
||||||
|
return postCall("/payments/intent", {userid, price, description});
|
||||||
|
},
|
||||||
|
paymentRegister(userid, result){
|
||||||
|
return postCall("/payments/register/", {userid, result});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import API from './../API.js';
|
|||||||
import Post from './../components/Post.js';
|
import Post from './../components/Post.js';
|
||||||
import { Provider as PaperProvider } from 'react-native-paper';
|
import { Provider as PaperProvider } from 'react-native-paper';
|
||||||
import AwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
import AwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
||||||
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
||||||
|
import NewPost from "./../components/NewPost.js";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,11 +31,12 @@ let Feed = ({ navigation, route }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PaperProvider settings={{
|
<PaperProvider settings={{
|
||||||
icon: props => <AwesomeIcon {...props} />,
|
icon: props => <MaterialIcons {...props} />,
|
||||||
}}>
|
}}>
|
||||||
<SafeAreaView style={styles.container}>
|
<SafeAreaView style={styles.container}>
|
||||||
<View>
|
<View>
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
|
<NewPost />
|
||||||
{
|
{
|
||||||
Posts.map((post, i) => {
|
Posts.map((post, i) => {
|
||||||
return (
|
return (
|
||||||
@@ -57,6 +60,7 @@ const styles = StyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
backgroundColor: "#edf2f7"
|
backgroundColor: "#edf2f7",
|
||||||
|
width: "100%"
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,36 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Text, View, TextInput, Button, StyleSheet } from 'react-native';
|
import { View, StyleSheet } from 'react-native';
|
||||||
|
import { TextInput, Button } from 'react-native-paper';
|
||||||
import API from './../API.js';
|
import API from './../API.js';
|
||||||
|
import { useNavigation } from '@react-navigation/native';
|
||||||
|
|
||||||
|
|
||||||
let NewPost = ()=>{
|
let NewPost = () => {
|
||||||
let [query, setQuery] = useState('');
|
let [postContent, setPostContent] = useState('');
|
||||||
|
const navigation = useNavigation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.mainView}>
|
<View style={styles.newPost}>
|
||||||
|
<TextInput
|
||||||
|
label="New Post"
|
||||||
|
value={postContent}
|
||||||
|
onChangeText={setPostContent}
|
||||||
|
mode="outlined"
|
||||||
|
multiline={true}
|
||||||
|
/>
|
||||||
|
{
|
||||||
|
postContent ? (
|
||||||
|
<View style={{ flexDirection: "row", justifyContent: 'flex-end' }}>
|
||||||
|
<Button icon="add-a-photo" mode="outlined"></Button>
|
||||||
|
<Button icon="send" mode="outlined" onPress={() => {
|
||||||
|
API.newPost(postContent).then((newPost) => {
|
||||||
|
console.log(newPost);
|
||||||
|
setPostContent('')
|
||||||
|
});
|
||||||
|
}}>Post</Button>
|
||||||
|
</View>
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -15,5 +38,8 @@ let NewPost = ()=>{
|
|||||||
|
|
||||||
export default NewPost;
|
export default NewPost;
|
||||||
|
|
||||||
const styles = StyleSheet.create ({
|
const styles = StyleSheet.create({
|
||||||
|
newPost: {
|
||||||
|
margin: 10
|
||||||
|
}
|
||||||
});
|
});
|
||||||
@@ -24,10 +24,10 @@ let Post = ({ post, viewer }) => {
|
|||||||
|
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
<Card.Actions style={{ flexDirection: "row", flow: 4, justifyContent: 'space-evenly' }}>
|
<Card.Actions style={{ flexDirection: "row", flow: 4, justifyContent: 'space-evenly' }}>
|
||||||
<Button icon={post.reactions[viewer._id] ? "heart" : "heart-o"} style={{ flow: 1 }} >{Object.keys(post.reactions).length}</Button>
|
<Button icon={post.reactions[viewer._id] ? "favorite" : "favorite-border"} style={{ flow: 1 }} >{Object.keys(post.reactions).length}</Button>
|
||||||
<Button icon="comment-o" style={{ flow: 1 }} onPress={()=>{changeshowCommentsB(!showCommentsB)}} >{post.comments.length}</Button>
|
<Button icon="forum" style={{ flow: 1 }} onPress={()=>{changeshowCommentsB(!showCommentsB)}} >{post.comments.length}</Button>
|
||||||
<Button icon="share-square-o" style={{ flow: 1 }} ></Button>
|
<Button icon="ios-share" style={{ flow: 1 }} ></Button>
|
||||||
<Button icon={!post.bookmarks || !post.bookmarks.includes(viewer._id) ? "bookmark-o" : "bookmark"} style={{ flow: 1 }} ></Button>
|
<Button icon={!post.bookmarks || !post.bookmarks.includes(viewer._id) ? "bookmark-outline" : "bookmark"} style={{ flow: 1 }} ></Button>
|
||||||
</Card.Actions>
|
</Card.Actions>
|
||||||
{
|
{
|
||||||
showCommentsB &&
|
showCommentsB &&
|
||||||
|
|||||||
Reference in New Issue
Block a user