-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathEmptyStateIndicator.tsx
More file actions
93 lines (87 loc) · 2.89 KB
/
EmptyStateIndicator.tsx
File metadata and controls
93 lines (87 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, { useMemo } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { useTheme } from '../../contexts/themeContext/ThemeContext';
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
import { MessageBubbleEmpty } from '../../icons';
import { primitives } from '../../theme';
export type EmptyStateProps = {
listType?: 'channel' | 'message' | 'threads' | 'default';
};
export const EmptyStateIndicator = ({ listType }: EmptyStateProps) => {
const {
theme: {
emptyStateIndicator: { channelContainer, channelTitle, messageContainer, messageTitle },
semantics,
},
} = useTheme();
const { t } = useTranslationContext();
const styles = useStyles();
switch (listType) {
case 'channel':
return (
<View style={[styles.container, channelContainer]}>
<MessageBubbleEmpty height={27} stroke={semantics.textTertiary} width={25} />
<Text style={[styles.channelTitle, channelTitle]} testID='empty-channel-state-title'>
{t('No conversations yet')}
</Text>
</View>
);
case 'message':
return (
<View style={[styles.container, messageContainer]}>
<MessageBubbleEmpty height={27} stroke={semantics.textTertiary} width={25} />
<Text style={[styles.messageTitle, messageTitle]}>{t('No chats here yet…')}</Text>
</View>
);
case 'threads':
return (
<View style={styles.container}>
<MessageBubbleEmpty height={27} stroke={semantics.textTertiary} width={25} />
<Text style={styles.threadText}>{t('Reply to a message to start a thread')}</Text>
</View>
);
default:
return (
<Text style={[{ color: semantics.textSecondary }, messageContainer]}>No items exist</Text>
);
}
};
const useStyles = () => {
const {
theme: { semantics },
} = useTheme();
return useMemo(() => {
return StyleSheet.create({
channelDetails: {
fontSize: 14,
textAlign: 'center',
},
channelTitle: {
color: semantics.textSecondary,
fontSize: primitives.typographyFontSizeMd,
fontWeight: primitives.typographyFontWeightRegular,
lineHeight: primitives.typographyLineHeightNormal,
textAlign: 'center',
paddingVertical: primitives.spacingSm,
},
container: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
messageTitle: {
fontSize: 20,
fontWeight: 'bold',
paddingBottom: 8,
},
threadText: {
color: semantics.textSecondary,
fontSize: primitives.typographyFontSizeMd,
fontWeight: primitives.typographyFontWeightRegular,
lineHeight: primitives.typographyLineHeightNormal,
textAlign: 'center',
paddingVertical: primitives.spacingSm,
},
});
}, [semantics]);
};