11import React from 'react' ;
2- import { View } from 'react-native' ;
32import styled from '@stream-io/styled-components' ;
43import PropTypes from 'prop-types' ;
54import { 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+ ` ;
712const LoadingText = styled . Text `
813 margin-top: 20px;
914 font-size: 14px;
1015 font-weight: 600;
16+ ${ ( { theme } ) => theme . loadingIndicator . loadingText . css }
1117` ;
1218
1319export 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 }
0 commit comments