Skip to content

Commit 9d1c76a

Browse files
Merge pull request #129 from GetStream/vishal/CRNS-63
CRNS-63: Adding style and text customizability to LoadingIndicator
2 parents 9c8f1f0 + 232241c commit 9d1c76a

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

src/components/LoadingIndicator.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import React from 'react';
2-
import { View } from 'react-native';
32
import styled from '@stream-io/styled-components';
43
import PropTypes from 'prop-types';
54
import { Spinner } from './Spinner';
65

6+
const Container = styled.View`
7+
flex: 1;
8+
justify-content: center;
9+
align-items: center;
10+
${({ theme }) => theme.loadingIndicator.container.css}
11+
`;
712
const LoadingText = styled.Text`
813
margin-top: 20px;
914
font-size: 14px;
1015
font-weight: 600;
16+
${({ theme }) => theme.loadingIndicator.loadingText.css}
1117
`;
1218

1319
export class LoadingIndicator extends React.PureComponent {
1420
static propTypes = {
1521
listType: PropTypes.oneOf(['channel', 'message', 'default']),
22+
loadingText: PropTypes.string,
1623
};
1724

1825
static defaultProps = {
@@ -23,31 +30,35 @@ export class LoadingIndicator extends React.PureComponent {
2330
switch (this.props.listType) {
2431
case 'channel':
2532
return (
26-
<View
27-
style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
28-
>
33+
<Container>
2934
<Spinner />
30-
<LoadingText>Loading channels ...</LoadingText>
31-
</View>
35+
<LoadingText>
36+
{this.props.loadingText
37+
? this.props.loadingText
38+
: 'Loading channels ...'}
39+
</LoadingText>
40+
</Container>
3241
);
3342
case 'message':
3443
return (
35-
<View
36-
style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
37-
>
44+
<Container>
3845
<Spinner />
39-
<LoadingText>Loading messages ...</LoadingText>
40-
</View>
46+
<LoadingText>
47+
{this.props.loadingText
48+
? this.props.loadingText
49+
: 'Loading messages ...'}
50+
</LoadingText>
51+
</Container>
4152
);
4253
case 'default':
4354
default:
4455
return (
45-
<View
46-
style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
47-
>
56+
<Container>
4857
<Spinner />
49-
<LoadingText>Loading ...</LoadingText>
50-
</View>
58+
<LoadingText>
59+
{this.props.loadingText ? this.props.loadingText : 'Loading ...'}
60+
</LoadingText>
61+
</Container>
5162
);
5263
}
5364
}

src/styles/theme.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ export const defaultTheme = {
161161
cancelButtonText: {},
162162
},
163163
},
164-
164+
loadingIndicator: {
165+
container: {},
166+
loadingText: {},
167+
},
165168
messageInput: {
166169
container: {
167170
conditionalPadding: 20,

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ export interface LoadingErrorIndicatorProps {
643643
}
644644
export interface LoadingIndicatorProps {
645645
listType?: listType;
646+
loadingText?: string;
646647
}
647648
export interface MentionsItemProps {
648649
item: {

0 commit comments

Comments
 (0)