Skip to content

Commit

Permalink
Grouplist updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Snehasish1303roy committed Nov 19, 2020
1 parent 8ae296e commit 07a8222
Show file tree
Hide file tree
Showing 18 changed files with 326 additions and 151 deletions.
Binary file added assets/images/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/components/Avatar/Avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { Component } from 'react';
import { View, Image } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons';

import Images from '../../config/image';
import styles from './styles';
import PropTypes from 'prop-types';

export default class Avatar extends Component {
render() {
const { uri, large, isGroup, enableDot } = this.props;

return (
<View style={large ? styles.avatarLargeView : styles.avatarView}>
{isGroup ? (
<Icon name="face" size={64} color="grey" />
) : (
<Image
source={uri ? { uri: uri } : Images.profile.avatar}
style={large ? styles.avatarLarge : styles.avatar}
/>
)}
{enableDot ? (
<View
style={large ? styles.statusDotLarge : styles.statusDot}
/>
) : (
<View style={{}} />
)}
</View>
);
}
}

Avatar.defultProps = {
enableDot: true,
large: false,
isGroup: false,
liveEnabled: true
};

Avatar.propTypes = {
large: PropTypes.bool,
isGroup: PropTypes.bool,
enableDot: PropTypes.bool,
uri: PropTypes.string
};
2 changes: 2 additions & 0 deletions src/components/Avatar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Avatar from './Avatar';
export default Avatar;
53 changes: 53 additions & 0 deletions src/components/Avatar/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { StyleSheet } from 'react-native';
import AppStyles from '../../config/styles';

const styles = StyleSheet.create({
avatarView: {
width: 48,
height: 48,
backgroundColor: AppStyles.colors.separator,
borderRadius: 24
},
avatar: {
width: 48,
height: 48,
borderRadius: 24,
overflow: 'hidden'
},
statusDot: {
position: 'absolute',
bottom: 0,
right: 0,
width: 16,
height: 16,
borderRadius: 9,
borderWidth: 2,
borderColor: AppStyles.colors.white,
backgroundColor: AppStyles.colors.onlineGreen
},
avatarLargeView: {
width: 64,
height: 64,
backgroundColor: AppStyles.colors.separator,
borderRadius: 32
},
avatarLarge: {
width: 64,
height: 64,
borderRadius: 32,
overflow: 'hidden'
},
statusDotLarge: {
position: 'absolute',
bottom: 0,
right: 0,
width: 20,
height: 20,
borderRadius: 10,
borderWidth: 2,
borderColor: AppStyles.colors.white,
backgroundColor: AppStyles.colors.onlineGreen
}
});

export default styles;
38 changes: 38 additions & 0 deletions src/components/GroupsList/GroupItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React, { Component } from 'react';
import { View } from 'react-native';
import { Card, Text } from 'react-native-paper';

import Avatar from '../Avatar';
import styles from './styles';
import PropTypes from 'prop-types';

export default class GroupItem extends Component {
onPress = () => {
alert('Pressed');
};
render() {
const { item } = this.props;
return (
<Card style={styles.card} onPress={this.onPress}>
<View style={styles.cardView}>
<View style={styles.nameView}>
<Avatar large isGroup />
<Text style={styles.nameText}>{item.name}</Text>
<Text style={styles.last}>
Active {item.last_active}
</Text>
</View>
<View style={styles.footer}>
<Text numberOflines={2} style={styles.members}>
{item.members}
</Text>
</View>
</View>
</Card>
);
}
}

GroupItem.propTypes = {
item: PropTypes.object
};
64 changes: 64 additions & 0 deletions src/components/GroupsList/GroupsList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React, { Component } from 'react';
import { FlatList } from 'react-native';
import GroupsItem from './GroupItem';
import styles from './styles';

const data = [
{
name: 'React Native Community',
last_active: '15 days ago',
members: 'Vicky, Alex Jacob, Bob, William + 320'
},
{
name: 'Android Developers Forum',
last_active: '30 days ago',
members: 'Vicky, Alex, Bob, William + 256'
},
{
name: 'iOs Developers',
last_active: '30 days ago',
members: 'Tom Jacob, Alex Jacob,Thomas Paul + 400'
},
{
name: 'Buddies',
last_active: '10 days ago',
members: 'Vicky, Alex, Bob, William + 356'
},
{
name: 'Birthday Celebration',
last_active: '5 days ago',
members: 'Tom Alex, Jacob Samuel, Sam, +12'
},
{
name: 'College Buddies',
last_active: '24 days ago',
members: 'Vicky, Alex, Bob, William + 10'
},
{
name: 'Memories',
last_active: '1 day ago',
members: 'Tom Manuel, Jacob Augustin,Sam TOny +2'
},
{
name: 'Secret Group',
last_active: '28 days ago',
members: 'Tom Alex,Jacob Mathews,Sam Tony'
}
];

export default class GroupsList extends Component {
renderItem = ({ item }) => {
return <GroupsItem item={item} />;
};

render() {
return (
<FlatList
data={data}
contentContainerStyle={styles.list}
renderItem={this.renderItem}
showsVerticalScrollIndicator={false}
/>
);
}
}
2 changes: 2 additions & 0 deletions src/components/GroupsList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import GroupsList from './GroupsList';
export default GroupsList;
54 changes: 54 additions & 0 deletions src/components/GroupsList/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { StyleSheet } from 'react-native';
import AppStyles from '../../config/styles';
import Metrics from '../../config/metrics';

const styles = StyleSheet.create({
card: {
width: Metrics.screenWidth / 2.5,
height: Metrics.screenHeight / 3.6,
margin: 5
},
cardView: {
width: Metrics.screenWidth / 2.5,
height: Metrics.screenHeight / 3.6,
justifyContent: 'space-between',
alignItems: 'center'
},
footer: {
width: Metrics.screenWidth / 2.5 - 16,
paddingVertical: 22,
alignItems: 'center',
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: AppStyles.colors.separator
},
nameView: {
alignItems: 'center',
padding: 8,
paddingTop: 16
},
nameText: {
marginTop: 8,
color: AppStyles.colors.black,
fontSize: 15,
textAlign: 'center'
},
last: {
marginTop: 4,
color: AppStyles.colors.grey,
fontSize: 12,
textAlign: 'center'
},
members: {
color: AppStyles.colors.grey,
fontSize: 12,
textAlign: 'center'
},
list: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
alignItems: 'center'
}
});

export default styles;
8 changes: 8 additions & 0 deletions src/config/image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const images = {
profile: {
avatar: require('../../assets/images/avatar.png'),
wave: require('../../assets/images/wave.png')
}
};

export default images;
13 changes: 13 additions & 0 deletions src/config/metrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* platform/application wide metrics for proper styling
*/
import { Dimensions, Platform } from 'react-native';
const { width, height } = Dimensions.get('window');

const metrics = {
screenWidth: width < height ? width : height,
screenHeight: width < height ? height : width,
navBarHeight: Platform.OS === 'ios' ? 54 : 66
};

export default metrics;
22 changes: 22 additions & 0 deletions src/config/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const AppStyles = {
colors: {
accentColor: '#0084ff',
inactiveGreyColor: '#626262',
lightGreyCOlor: '#7f8c8d',
separator: '#bdc3c7',
white: 'white',
black: 'black',
grey: 'grey',
green: 'green',
onlineGreen: '#2ecc71',
lightWhite: '#f9f9f9'
},
fonts: {
FONT_REGULAR: 'Roboto-Regular',
FONT_MEDIUM: 'Roboto-Medium',
FONT_LIGHT: 'Roboto-Light',
FONT_THIN: 'Roboto-Thin'
}
};

export default AppStyles;
20 changes: 1 addition & 19 deletions src/navigation/AppStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
ScanScreen,
ShareCodeScreen,
SafetyMeasuresScreen,
DetailsScreen,
SampleScreen
DetailsScreen
} from '../screens';


Expand Down Expand Up @@ -115,23 +114,6 @@ const HomeStack = ({ navigation }) => (
}
}}
/>
<Stack.Screen
name="SampleScreen"
component={SampleScreen}
options={{
title: 'This is a sample screen',
headerTitleAlign: 'center',
headerTitleStyle: {
color: '#2e64e5',
fontFamily: 'Kufam-SemiBoldItalic',
fontSize: 18
},
headerStyle: {
shadowColor: '#fff',
elevation: 0,
}
}}
/>
</Stack.Navigator>
);

Expand Down
Loading

0 comments on commit 07a8222

Please sign in to comment.