Improving groups
This commit is contained in:
3
API.js
3
API.js
@@ -257,6 +257,9 @@ const API = {
|
|||||||
getRecentGroups() {
|
getRecentGroups() {
|
||||||
return getCall("/user/groups");
|
return getCall("/user/groups");
|
||||||
},
|
},
|
||||||
|
getFollowingGroups() {
|
||||||
|
return getCall("/user/groups/following");
|
||||||
|
},
|
||||||
searchGroups(query){
|
searchGroups(query){
|
||||||
return getCall("/user/groups/search", query ? {query} : {}).then((data)=>{
|
return getCall("/user/groups/search", query ? {query} : {}).then((data)=>{
|
||||||
if(data.status == "ok"){
|
if(data.status == "ok"){
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { Searchbar } from 'react-native-paper';
|
import { Searchbar, Title } from 'react-native-paper';
|
||||||
import { StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
import { StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
||||||
import API from "../API";
|
import API from "../API";
|
||||||
import GroupCard from "../components/GroupCard";
|
import GroupCard from "../components/GroupCard";
|
||||||
@@ -11,9 +11,9 @@ const Groups = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let subscribed = true;
|
let subscribed = true;
|
||||||
API.getRecentGroups('').then((data) => {
|
API.getFollowingGroups('').then((data) => {
|
||||||
if (subscribed)
|
if (subscribed)
|
||||||
setGroups(data.groups || []);
|
setGroups(data?.groups || []);
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
subscribed = false;
|
subscribed = false;
|
||||||
@@ -27,7 +27,7 @@ const Groups = () => {
|
|||||||
if (queryTimer) clearTimeout(queryTimer);
|
if (queryTimer) clearTimeout(queryTimer);
|
||||||
let timerId = setTimeout(() => {
|
let timerId = setTimeout(() => {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return API.getRecentGroups('').then((data) => {
|
return API.getFollowingGroups('').then((data) => {
|
||||||
setGroups(data.groups || []);
|
setGroups(data.groups || []);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -50,11 +50,11 @@ const Groups = () => {
|
|||||||
/>
|
/>
|
||||||
<FlatList
|
<FlatList
|
||||||
contentContainerStyle={styles.container}
|
contentContainerStyle={styles.container}
|
||||||
numColumns={2}
|
numColumns={1}
|
||||||
columnWrapperStyle={{ justifyContent: "space-evenly" }}
|
|
||||||
data={groups}
|
data={groups}
|
||||||
renderItem={renderProfile}
|
renderItem={renderProfile}
|
||||||
keyExtractor={item => item._id}
|
keyExtractor={item => item._id}
|
||||||
|
ListHeaderComponent={searchQuery ? <></> : <Title style={styles.title} >Groups you follow:</Title>}
|
||||||
/>
|
/>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
)
|
)
|
||||||
@@ -66,4 +66,11 @@ const styles = StyleSheet.create({
|
|||||||
container: {
|
container: {
|
||||||
padding: 5,
|
padding: 5,
|
||||||
},
|
},
|
||||||
|
title: {
|
||||||
|
padding: 10,
|
||||||
|
fontSize: 30,
|
||||||
|
marginTop: 15,
|
||||||
|
fontWeight: "bold",
|
||||||
|
color: "#777"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Text, StyleSheet, View } from 'react-native';
|
import { Text, StyleSheet, View } from 'react-native';
|
||||||
import Icon from 'react-native-vector-icons/MaterialIcons';
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
||||||
import { Avatar, Button, Card, Title, Paragraph } from 'react-native-paper';
|
import { List, IconButton, Card, Chip, Badge } from 'react-native-paper';
|
||||||
import API from './../API.js';
|
import API from './../API.js';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation } from '@react-navigation/native';
|
||||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
@@ -51,6 +51,7 @@ let ProfileCard = ({ profileid, hideIcon, profileObj }) => {
|
|||||||
let icon = profile._id ? (!profile.isGroup ? "person-outline" : "group") : '';
|
let icon = profile._id ? (!profile.isGroup ? "person-outline" : "group") : '';
|
||||||
icon = icon === "person-outline" && profile.subscription && profile.subscription > (new Date() - 0) ? "assignment-ind" : icon;
|
icon = icon === "person-outline" && profile.subscription && profile.subscription > (new Date() - 0) ? "assignment-ind" : icon;
|
||||||
icon = icon === "group" && profile.isCourse ? "subscriptions" : icon;
|
icon = icon === "group" && profile.isCourse ? "subscriptions" : icon;
|
||||||
|
icon = icon === "group" && profile.isPrivate ? "screen-lock-portrait" : icon;
|
||||||
let photoUrl = profile.profile.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto;
|
let photoUrl = profile.profile.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto;
|
||||||
|
|
||||||
const onPress = () => {
|
const onPress = () => {
|
||||||
@@ -60,22 +61,20 @@ let ProfileCard = ({ profileid, hideIcon, profileObj }) => {
|
|||||||
return (
|
return (
|
||||||
<Card style={styles.content}>
|
<Card style={styles.content}>
|
||||||
<Card.Content>
|
<Card.Content>
|
||||||
<Title onPress={onPress} numberOfLines={1}>
|
<IconButton icon={icon} style={{
|
||||||
<Text style={{ paddingTop: 10 }}>
|
position: "absolute",
|
||||||
{!hideIcon ? <Icon name={icon} size={18} /> : <></>}
|
right: 5,
|
||||||
</Text>
|
top: 5,
|
||||||
<Text>
|
}} />
|
||||||
{profile.profile && profile.profile.firstName} {profile.profile && profile.profile.lastName}
|
<List.Item
|
||||||
</Text>
|
title={profile.profile?.firstName + " " + profile.profile?.lastName}
|
||||||
</Title>
|
description={profileObj.profile.description}
|
||||||
<Paragraph numberOfLines={4}>{profileObj.profile.description}</Paragraph>
|
//left={props => <List.Icon {...props} icon={icon} />}
|
||||||
<View style={{flexDirection: "row", justifyContent:"space-evenly"}}>
|
titleStyle={{fontWeight:"bold", fontSize:20}}
|
||||||
<FollowButton profile={profile} />
|
descriptionStyle={{}}
|
||||||
<Text>
|
onPress={onPress}
|
||||||
<Icon name={"hail"} size={18} />
|
descriptionNumberOfLines={4}
|
||||||
{Object.keys(profile.subscribed).length}
|
/>
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -87,7 +86,6 @@ export default React.memo(ProfileCard);
|
|||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
content: {
|
content: {
|
||||||
margin: 4,
|
margin: 4,
|
||||||
width: "50%",
|
|
||||||
},
|
},
|
||||||
centerItems: {
|
centerItems: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
|||||||
Reference in New Issue
Block a user