-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathChannelListHeaderErrorIndicator.tsx
More file actions
55 lines (49 loc) · 1.74 KB
/
ChannelListHeaderErrorIndicator.tsx
File metadata and controls
55 lines (49 loc) · 1.74 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
import React, { useMemo } from 'react';
import { GestureResponderEvent, StyleSheet, Text, TouchableOpacity } from 'react-native';
import { useTheme } from '../../contexts/themeContext/ThemeContext';
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
import { primitives } from '../../theme';
export type HeaderErrorProps = {
onPress?: (event: GestureResponderEvent) => void;
};
export const ChannelListHeaderErrorIndicator = ({ onPress = () => null }: HeaderErrorProps) => {
const styles = useStyles();
const { t } = useTranslationContext();
return (
<TouchableOpacity onPress={onPress} style={styles.container}>
<Text style={styles.errorText} testID='channel-loading-error'>
{t('Error while loading, please reload/refresh')}
</Text>
</TouchableOpacity>
);
};
ChannelListHeaderErrorIndicator.displayName =
'ChannelListHeaderErrorIndicator{channelListHeaderErrorIndicator}';
const useStyles = () => {
const {
theme: {
channelListHeaderErrorIndicator: { container, errorText },
semantics,
},
} = useTheme();
return useMemo(() => {
return StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
width: '100%',
backgroundColor: semantics.backgroundCoreSurface,
paddingVertical: primitives.spacingXs,
paddingHorizontal: primitives.spacingSm,
...container,
},
errorText: {
fontSize: primitives.typographyFontSizeXs,
fontWeight: primitives.typographyFontWeightSemiBold,
lineHeight: primitives.typographyLineHeightTight,
color: semantics.chatTextSystem,
...errorText,
},
});
}, [container, errorText, semantics]);
};