import React from 'react'; import PropTypes from 'prop-types'; import { View, Text, TouchableWithoutFeedback } from 'react-native'; import styles from './styles'; import { themes } from '../../constants/colors'; import DisclosureIndicator from '../../containers/DisclosureIndicator'; export default class Button extends React.PureComponent { static propTypes = { title: PropTypes.string, subtitle: PropTypes.string, type: PropTypes.string, theme: PropTypes.string, icon: PropTypes.node.isRequired, testID: PropTypes.string.isRequired, onPress: PropTypes.func } static defaultProps = { title: 'Press me!', type: 'primary', onPress: () => alert('It works!') } state = { active: false }; render() { const { title, subtitle, type, onPress, icon, testID, theme } = this.props; const { active } = this.state; const activeStyle = active && styles.buttonActive; const isPrimary = (type === 'primary'); const buttonContainerStyle = { backgroundColor: isPrimary ? themes[theme].actionTintColor : themes[theme].focusedBackground, borderColor: isPrimary ? themes[theme].actionTintColor : themes[theme].borderColor }; return ( this.setState({ active: true })} onPressOut={() => this.setState({ active: false })} testID={testID} > {icon} {title} {subtitle ? {subtitle} : null} {type === 'secondary' ? : null} ); } }