Skip to content

Commit 2944c07

Browse files
authored
fix: add theme properties for EmptyStateIndicator for message list (#2667)
* fix: add theme properties for EmptyStateIndicator for message list * fix: update snapshots
1 parent aea64f1 commit 2944c07

File tree

6 files changed

+72
-67
lines changed

6 files changed

+72
-67
lines changed

package/src/components/Indicators/EmptyStateIndicator.tsx

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,6 @@ import { useTranslationContext } from '../../contexts/translationContext/Transla
66
import { useViewport } from '../../hooks/useViewport';
77
import { ChatIcon, MessageIcon } from '../../icons';
88

9-
const styles = StyleSheet.create({
10-
channelContainer: {
11-
alignItems: 'center',
12-
flex: 1,
13-
justifyContent: 'center',
14-
},
15-
channelDetails: {
16-
fontSize: 14,
17-
textAlign: 'center',
18-
},
19-
channelTitle: {
20-
fontSize: 16,
21-
paddingBottom: 8,
22-
paddingTop: 16,
23-
},
24-
messageContainer: {
25-
alignItems: 'center',
26-
flex: 1,
27-
justifyContent: 'center',
28-
},
29-
messageTitle: {
30-
fontSize: 20,
31-
fontWeight: 'bold',
32-
paddingBottom: 8,
33-
},
34-
});
35-
369
export type EmptyStateProps = {
3710
listType?: 'channel' | 'message' | 'default';
3811
};
@@ -41,7 +14,13 @@ export const EmptyStateIndicator = ({ listType }: EmptyStateProps) => {
4114
const {
4215
theme: {
4316
colors: { black, grey, grey_gainsboro },
44-
emptyStateIndicator: { channelContainer, channelDetails, channelTitle },
17+
emptyStateIndicator: {
18+
channelContainer,
19+
channelDetails,
20+
channelTitle,
21+
messageContainer,
22+
messageTitle,
23+
},
4524
},
4625
} = useTheme();
4726
const { vw } = useViewport();
@@ -51,7 +30,7 @@ export const EmptyStateIndicator = ({ listType }: EmptyStateProps) => {
5130
switch (listType) {
5231
case 'channel':
5332
return (
54-
<View style={[styles.channelContainer, channelContainer]}>
33+
<View style={[styles.container, channelContainer]}>
5534
<MessageIcon height={width} pathFill={grey_gainsboro} width={width} />
5635
<Text
5736
style={[styles.channelTitle, { color: black }, channelTitle]}
@@ -69,14 +48,36 @@ export const EmptyStateIndicator = ({ listType }: EmptyStateProps) => {
6948
);
7049
case 'message':
7150
return (
72-
<View style={[styles.messageContainer]}>
51+
<View style={[styles.container, messageContainer]}>
7352
<ChatIcon height={width} pathFill={grey_gainsboro} width={width} />
74-
<Text style={[styles.messageTitle, { color: grey_gainsboro }]}>
53+
<Text style={[styles.messageTitle, { color: grey_gainsboro }, messageTitle]}>
7554
{t<string>('No chats here yet…')}
7655
</Text>
7756
</View>
7857
);
7958
default:
80-
return <Text style={{ color: black }}>No items exist</Text>;
59+
return <Text style={[{ color: black }, messageContainer]}>No items exist</Text>;
8160
}
8261
};
62+
63+
const styles = StyleSheet.create({
64+
channelDetails: {
65+
fontSize: 14,
66+
textAlign: 'center',
67+
},
68+
channelTitle: {
69+
fontSize: 16,
70+
paddingBottom: 8,
71+
paddingTop: 16,
72+
},
73+
container: {
74+
alignItems: 'center',
75+
flex: 1,
76+
justifyContent: 'center',
77+
},
78+
messageTitle: {
79+
fontSize: 20,
80+
fontWeight: 'bold',
81+
paddingBottom: 8,
82+
},
83+
});

package/src/components/Indicators/LoadingDot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export const LoadingDot = (props: Props) => {
6262
width: diameter,
6363
},
6464
style,
65-
loadingDot,
6665
dotStyle,
66+
loadingDot,
6767
]}
6868
/>
6969
);

package/src/components/Indicators/LoadingErrorIndicator.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@ import { StyleSheet, Text, TouchableOpacity } from 'react-native';
44
import { useTheme } from '../../contexts/themeContext/ThemeContext';
55
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
66

7-
const styles = StyleSheet.create({
8-
container: {
9-
alignItems: 'center',
10-
height: '100%',
11-
justifyContent: 'center',
12-
width: '100%',
13-
},
14-
errorText: {
15-
fontSize: 14,
16-
fontWeight: '600',
17-
marginTop: 20,
18-
},
19-
retryText: {
20-
fontSize: 30,
21-
fontWeight: '600',
22-
},
23-
});
24-
257
type LoadingErrorWrapperProps = {
268
text: string;
279
onPress?: () => void;
@@ -85,3 +67,21 @@ export const LoadingErrorIndicator = (props: LoadingErrorProps) => {
8567
};
8668

8769
LoadingErrorIndicator.displayName = 'LoadingErrorIndicator{loadingErrorIndicator}';
70+
71+
const styles = StyleSheet.create({
72+
container: {
73+
alignItems: 'center',
74+
height: '100%',
75+
justifyContent: 'center',
76+
width: '100%',
77+
},
78+
errorText: {
79+
fontSize: 14,
80+
fontWeight: '600',
81+
marginTop: 20,
82+
},
83+
retryText: {
84+
fontSize: 30,
85+
fontWeight: '600',
86+
},
87+
});

package/src/components/Indicators/LoadingIndicator.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,6 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
55
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
66
import { Spinner } from '../Spinner/Spinner';
77

8-
const styles = StyleSheet.create({
9-
container: {
10-
alignItems: 'center',
11-
flex: 1,
12-
justifyContent: 'center',
13-
},
14-
loadingText: {
15-
fontSize: 14,
16-
fontWeight: '600',
17-
marginTop: 20,
18-
},
19-
});
20-
218
type LoadingIndicatorWrapperProps = { text: string };
229

2310
const LoadingIndicatorWrapper = ({ text }: LoadingIndicatorWrapperProps) => {
@@ -66,3 +53,16 @@ export const LoadingIndicator = (props: LoadingProps) => {
6653
};
6754

6855
LoadingIndicator.displayName = 'LoadingIndicator{loadingIndicator}';
56+
57+
const styles = StyleSheet.create({
58+
container: {
59+
alignItems: 'center',
60+
flex: 1,
61+
justifyContent: 'center',
62+
},
63+
loadingText: {
64+
fontSize: 14,
65+
fontWeight: '600',
66+
marginTop: 20,
67+
},
68+
});

package/src/components/MessageList/__tests__/__snapshots__/TypingIndicator.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
4343
{
4444
"marginRight": 2,
4545
},
46-
{},
4746
{
4847
"opacity": -0.3333333333333333,
4948
},
49+
{},
5050
]
5151
}
5252
/>
@@ -62,10 +62,10 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
6262
{
6363
"marginHorizontal": 2,
6464
},
65-
{},
6665
{
6766
"opacity": 0.3333333333333333,
6867
},
68+
{},
6969
]
7070
}
7171
/>
@@ -81,10 +81,10 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
8181
{
8282
"marginLeft": 2,
8383
},
84-
{},
8584
{
8685
"opacity": 1,
8786
},
87+
{},
8888
]
8989
}
9090
/>

package/src/contexts/themeContext/utils/theme.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ export type Theme = {
167167
channelContainer: ViewStyle;
168168
channelDetails: TextStyle;
169169
channelTitle: TextStyle;
170+
messageContainer: ViewStyle;
171+
messageTitle: TextStyle;
170172
};
171173
groupAvatar: {
172174
container: ViewStyle;
@@ -753,6 +755,8 @@ export const defaultTheme: Theme = {
753755
channelContainer: {},
754756
channelDetails: {},
755757
channelTitle: {},
758+
messageContainer: {},
759+
messageTitle: {},
756760
},
757761
groupAvatar: {
758762
container: {},

0 commit comments

Comments
 (0)