// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import {ActivityIndicator, StyleSheet, TouchableHighlight, View} from 'react-native'; import {GlobalStyles} from 'app/styles'; const styles = StyleSheet.create({ container: { flex: 1, flexDirection: 'row', }, loading: { marginLeft: 3, }, }); export default class Button extends PureComponent { static propTypes = { children: PropTypes.node, loading: PropTypes.bool, onPress: PropTypes.func.isRequired, }; onPress = () => { if (!this.props.loading) { this.props.onPress(); } }; render() { let loading = null; if (this.props.loading) { loading = ( ); } return ( {this.props.children} {loading} ); } }