Skip to content

Commit 66ca5d4

Browse files
feat(communities): PEDAGO-2911 adding members list
1 parent c27e67f commit 66ca5d4

File tree

24 files changed

+442
-21
lines changed

24 files changed

+442
-21
lines changed

assets/i18n/fr.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@
337337
"communities-list-empty-title": "C'est calme... pour l'instant !",
338338
"communities-member": "membre",
339339
"communities-members": "membres",
340+
"communities-members-list-empty-text": "Ajoutez des membres à la communauté à partir de la version web de Communautés.",
341+
"communities-members-list-empty-title": "Une communauté, c'est mieux à plusieurs !",
340342
"communities-badge-new": "Nouveau",
343+
"communities-role-admin": "Gestionnaire",
344+
"communities-role-member": "Membre",
341345
"competences-assessment-levellegendmodal-title": "Légende",
342346
"competences-home-averages": "Moyennes",
343347
"competences-home-colors": "Couleurs",
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from 'react';
2+
import { View, ViewStyle } from 'react-native';
3+
4+
import styles from './styles';
5+
import { VisibleItemProps } from './types';
6+
7+
import theme from '~/app/theme';
8+
import { SingleAvatar } from '~/framework/components/avatar';
9+
10+
const VisibleItem = ({ avatarSize = 'md', children, isItemEven, isListReadonly, rightElement, userId }: VisibleItemProps) => {
11+
const backgroundColorStyle: ViewStyle | undefined = React.useMemo(() => {
12+
return !isItemEven ? { backgroundColor: theme.palette.grey.fog } : undefined;
13+
}, [isItemEven]);
14+
15+
return (
16+
<View style={[backgroundColorStyle, styles.container]}>
17+
<SingleAvatar size={avatarSize} userId={userId} style={styles.flex0} />
18+
<View style={styles.flex1}>{children}</View>
19+
{!isListReadonly && <View style={styles.flex0}>{rightElement}</View>}
20+
</View>
21+
);
22+
};
23+
24+
export default VisibleItem;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import VisibleItem from './component';
2+
import VisibleItemLoader from './loader/component';
3+
4+
export { VisibleItemLoader };
5+
export default VisibleItem;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { View, ViewStyle } from 'react-native';
3+
4+
import { Fade, Placeholder, PlaceholderMedia } from 'rn-placeholder';
5+
6+
import theme from '~/app/theme';
7+
import { AvatarSizes } from '~/framework/components/avatar/styles';
8+
import styles from '~/framework/components/card/visible-item/styles';
9+
import { VisibleItemLoaderProps } from '~/framework/components/card/visible-item/types';
10+
import { UI_SIZES } from '~/framework/components/constants';
11+
12+
const VisibleItemLoader = ({ avatarSize = 'md', children, isItemEven }: VisibleItemLoaderProps) => {
13+
const avatarWidth = React.useMemo(() => {
14+
return AvatarSizes[avatarSize] + UI_SIZES.border.small * 2;
15+
}, [avatarSize]);
16+
17+
const backgroundColorStyle: ViewStyle | undefined = React.useMemo(() => {
18+
return !isItemEven ? { backgroundColor: theme.palette.grey.fog } : undefined;
19+
}, [isItemEven]);
20+
21+
return (
22+
<View style={[backgroundColorStyle, styles.container]}>
23+
<View style={[styles.flex0, { width: avatarWidth }]}>
24+
<Placeholder Animation={Fade}>
25+
<PlaceholderMedia isRound size={avatarWidth} />
26+
</Placeholder>
27+
</View>
28+
<View style={styles.flex1}>{children}</View>
29+
</View>
30+
);
31+
};
32+
33+
export default VisibleItemLoader;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
import { UI_SIZES } from '~/framework/components/constants';
4+
5+
export default StyleSheet.create({
6+
container: {
7+
alignItems: 'center',
8+
flexDirection: 'row',
9+
paddingHorizontal: UI_SIZES.spacing.big,
10+
paddingVertical: UI_SIZES.spacing.small,
11+
},
12+
flex0: {
13+
flex: 0,
14+
},
15+
flex1: {
16+
flex: 1,
17+
marginHorizontal: UI_SIZES.spacing.small,
18+
},
19+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Size } from '~/framework/components/avatar';
2+
3+
export interface VisibleItemProps {
4+
avatarSize?: Size | keyof typeof Size;
5+
children: React.ReactNode;
6+
isItemEven?: boolean;
7+
isListReadonly?: boolean;
8+
rightElement?: React.ReactNode;
9+
userId: string;
10+
}
11+
12+
export type VisibleItemLoaderProps = Omit<VisibleItemProps, 'isListReadonly' | 'rightElement' | 'userId'>;

src/framework/components/picture/svg/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ const imports = {
213213
'ui-move': async () => import('ASSETS/icons/uiIcons/move.svg'),
214214
'ui-notif': async () => import('ASSETS/icons/uiIcons/notif.svg'),
215215
'ui-options': async () => import('ASSETS/icons/uiIcons/options.svg'),
216+
'ui-options-horizontal': async () => import('ASSETS/icons/uiIcons/options-horizontal.svg'),
216217
'ui-orderedList': async () => import('ASSETS/icons/uiIcons/orderedList.svg'),
217218
'ui-pause': async () => import('ASSETS/icons/uiIcons/pause.svg'),
218219
'ui-personBook': async () => import('ASSETS/icons/uiIcons/person_book.svg'),
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import * as React from 'react';
2+
import { View } from 'react-native';
3+
4+
import styles from './styles';
5+
import { MemberListItemProps } from './types';
6+
7+
import { I18n } from '~/app/i18n';
8+
import theme from '~/app/theme';
9+
import { SmallBoldText, SmallText } from '~/framework/components/text';
10+
11+
const profileMap = {
12+
guest: {
13+
color: theme.palette.complementary.pink.regular,
14+
profileKey: 'guest',
15+
},
16+
personnel: {
17+
color: theme.palette.complementary.purple.regular,
18+
profileKey: 'personnel',
19+
},
20+
relative: {
21+
color: theme.palette.complementary.blue.regular,
22+
profileKey: 'relative',
23+
},
24+
student: {
25+
color: theme.palette.complementary.orange.regular,
26+
profileKey: 'student',
27+
},
28+
teacher: {
29+
color: theme.palette.complementary.green.regular,
30+
profileKey: 'teacher',
31+
},
32+
};
33+
34+
const MemberListItem: React.FC<MemberListItemProps> = ({ name, profileType, role }) => {
35+
const { color, profileKey } = profileMap[profileType.toLowerCase()] ?? {
36+
color: theme.palette.grey.black,
37+
profileKey: '',
38+
};
39+
const profileLabel = profileKey ? I18n.get(`user-profiletypes-${profileKey}`) : '';
40+
const roleLabel = role ? I18n.get(`communities-role-${role.toLowerCase()}`) : '';
41+
42+
return (
43+
<View style={styles.container}>
44+
<SmallBoldText numberOfLines={1}>{name}</SmallBoldText>
45+
<View style={styles.containerText}>
46+
<SmallBoldText style={{ color }}>{profileLabel}</SmallBoldText>
47+
<View style={styles.separator}>
48+
<SmallBoldText>|</SmallBoldText>
49+
</View>
50+
<SmallText>{roleLabel}</SmallText>
51+
</View>
52+
</View>
53+
);
54+
};
55+
56+
export default MemberListItem;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import MemberListItem from './component';
2+
import MemberListItemLoader from './loader/component';
3+
import ItemOptions from './options/component';
4+
import type { MemberProfileType } from './types';
5+
6+
export { ItemOptions, MemberListItemLoader };
7+
export type { MemberProfileType };
8+
9+
export default MemberListItem;

0 commit comments

Comments
 (0)