ActivityIndicator.js 1.46 KB
import React, {Component} from 'react'
import {
    StyleSheet,
    View,
    Text,
    Dimensions,
    ActivityIndicatorIOS,
    Platform,
    ProgressBarAndroid,
} from 'react-native';

export default class ActivityIndicator extends Component {

    renderFooter() {
        if (this.props.hidden) {
            return <View/>;
        }else {
            if (Platform.OS === 'android') {
                return (
                    <View style={styles.footerContainer}>
                        <ProgressBarAndroid style={styles.footerIndicator}/>
                        <Text style = {styles.footerText}>{this.props.loadingText}</Text>
                    </View>
                )
            } else {
                return (
                    <View style={styles.footerContainer}>
                        <ActivityIndicatorIOS style={styles.footerIndicator} size='small' animating={this.props.animating}/>
                        <Text style = {styles.footerText}>{this.props.loadingText}</Text>
                    </View>
            )
            }
        }
    }

    render() {
        return(
            this.renderFooter()
        );
    }
}

const styles = StyleSheet.create({

    footerContainer: {
        flexDirection: 'row',

    },
    footerIndicator: {
        marginTop: 15,
        marginLeft: Dimensions.get('window').width/2-50,
        marginRight: 10,
    },
    footerText: {
        marginTop: 17,
        textAlign: 'center',
        color:'#b1b1b1',
    },
});