'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports["default"] = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var React = _interopRequireWildcard(_react);

var _reactNative = require('react-native');

var _style = require('./style');

var _style2 = _interopRequireDefault(_style);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var RNActivityIndicator = function (_React$Component) {
    (0, _inherits3["default"])(RNActivityIndicator, _React$Component);

    function RNActivityIndicator() {
        (0, _classCallCheck3["default"])(this, RNActivityIndicator);
        return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
    }

    RNActivityIndicator.prototype._renderToast = function _renderToast() {
        return React.createElement(
            _reactNative.View,
            { style: [{
                    alignItems: 'center',
                    justifyContent: 'center',
                    width: 89,
                    height: 89,
                    borderRadius: 6,
                    backgroundColor: 'rgba(34,34,34,0.6)'
                }] },
            React.createElement(_reactNative.ActivityIndicator, { color: 'white', size: 'large' }),
            this.props.text && React.createElement(
                _reactNative.Text,
                { style: [_style2["default"].toast] },
                this.props.text
            )
        );
    };

    RNActivityIndicator.prototype._renderSpinner = function _renderSpinner() {
        return React.createElement(
            _reactNative.View,
            { style: [{
                    flexDirection: 'row',
                    justifyContent: 'center',
                    alignItems: 'center'
                }] },
            React.createElement(_reactNative.ActivityIndicator, { color: this.props.color, size: this.props.size }),
            this.props.text && React.createElement(
                _reactNative.Text,
                { style: [_style2["default"].tip] },
                this.props.text
            )
        );
    };

    RNActivityIndicator.prototype.render = function render() {
        if (this.props.animating) {
            return React.createElement(
                _reactNative.View,
                null,
                !!this.props.toast ? this._renderToast() : this._renderSpinner()
            );
        }
    };

    return RNActivityIndicator;
}(React.Component);

exports["default"] = RNActivityIndicator;

RNActivityIndicator.defaultProps = {
    animating: true,
    color: 'gray',
    size: 'small',
    panelColor: 'rgba(34,34,34,0.6)',
    toast: false
};
module.exports = exports['default'];