diff --git a/API.js b/API.js index 693518c..b923c08 100644 --- a/API.js +++ b/API.js @@ -257,6 +257,9 @@ const API = { getRecentGroups() { return getCall("/user/groups"); }, + getFollowingGroups() { + return getCall("/user/groups/following"); + }, searchGroups(query){ return getCall("/user/groups/search", query ? {query} : {}).then((data)=>{ if(data.status == "ok"){ diff --git a/Views/Groups.js b/Views/Groups.js index cea077a..3da19db 100644 --- a/Views/Groups.js +++ b/Views/Groups.js @@ -1,5 +1,5 @@ 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 API from "../API"; import GroupCard from "../components/GroupCard"; @@ -11,9 +11,9 @@ const Groups = () => { useEffect(() => { let subscribed = true; - API.getRecentGroups('').then((data) => { + API.getFollowingGroups('').then((data) => { if (subscribed) - setGroups(data.groups || []); + setGroups(data?.groups || []); }); return () => { subscribed = false; @@ -27,7 +27,7 @@ const Groups = () => { if (queryTimer) clearTimeout(queryTimer); let timerId = setTimeout(() => { if (!query) { - return API.getRecentGroups('').then((data) => { + return API.getFollowingGroups('').then((data) => { setGroups(data.groups || []); }); } @@ -50,11 +50,11 @@ const Groups = () => { /> item._id} + ListHeaderComponent={searchQuery ? <> : Groups you follow:} /> ) @@ -66,4 +66,11 @@ const styles = StyleSheet.create({ container: { padding: 5, }, + title: { + padding: 10, + fontSize: 30, + marginTop: 15, + fontWeight: "bold", + color: "#777" + } }); diff --git a/components/GroupCard.js b/components/GroupCard.js index db27dac..37ed6d2 100644 --- a/components/GroupCard.js +++ b/components/GroupCard.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Text, StyleSheet, View } from 'react-native'; 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 { useNavigation } from '@react-navigation/native'; 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") : ''; 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.isPrivate ? "screen-lock-portrait" : icon; let photoUrl = profile.profile.photo ? 'https://social.emmint.com/' + profile.profile.photo : DefaultPhoto; const onPress = () => { @@ -60,22 +61,20 @@ let ProfileCard = ({ profileid, hideIcon, profileObj }) => { return ( - - <Text style={{ paddingTop: 10 }}> - {!hideIcon ? <Icon name={icon} size={18} /> : <></>} - </Text> - <Text> - {profile.profile && profile.profile.firstName} {profile.profile && profile.profile.lastName} - </Text> - - {profileObj.profile.description} - - - - - {Object.keys(profile.subscribed).length} - - + + } + titleStyle={{fontWeight:"bold", fontSize:20}} + descriptionStyle={{}} + onPress={onPress} + descriptionNumberOfLines={4} + /> @@ -87,7 +86,6 @@ export default React.memo(ProfileCard); const styles = StyleSheet.create({ content: { margin: 4, - width: "50%", }, centerItems: { justifyContent: 'center',