mattermost-mobile/app/components/button.js
Jesse Hallam 58b72302d6 update eslint's comma-dangle rule to always-multiline (#1457)
* update eslint's `comma-dangle` rule to `always-multiline`

* add check and fix scripts to package.json

* Invoke `yarn fix` to adopt the updated eslint rules. No other changes are included.
2018-02-23 09:06:02 -05:00

60 lines
1.4 KiB
JavaScript

// Copyright (c) 2016-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 = (
<ActivityIndicator
style={styles.loading}
animating={true}
size='small'
/>
);
}
return (
<TouchableHighlight
style={GlobalStyles.button}
underlayColor='#B5B5B5'
onPress={this.onPress}
>
<View style={styles.container}>
{this.props.children}
{loading}
</View>
</TouchableHighlight>
);
}
}