import React from 'react'; import {ActivityIndicator, Text, View} from 'react-native'; import {WithTheme, WithThemeStyles} from '../style'; import ActivityIndicatorStyles, {ActivityIndicatorStyle} from './style'; export interface ActivityIndicatorNativeProps extends WithThemeStyles { styles?: ActivityIndicatorStyle; color?: string; animating?: boolean; toast?: boolean; size?: 'large' | 'small'; text?: string; } export default class RNActivityIndicator extends React.Component { static defaultProps = { animating: true, color: 'gray', size: 'small', toast: false, }; _renderToast() { const {color = 'white', size = 'large'} = this.props; return ( {(styles) => ( {this.props.text ? {this.props.text} : null} )} ); } _renderSpinner() { const {color, size, text} = this.props; return ( {(styles) => ( {text && {text}} )} ); } render() { if (this.props.animating) { return this.props.toast ? this._renderToast() : this._renderSpinner(); } return null; } }