import React from 'react'; import { StyleProp, StyleSheet, Text, TextStyle } from 'react-native'; import Touchable, { PlatformTouchableProps } from 'react-native-platform-touchable'; import { useTheme } from '../../theme'; import sharedStyles from '../../views/Styles'; import ActivityIndicator from '../ActivityIndicator'; interface IButtonProps extends PlatformTouchableProps { title: string; onPress: () => void; type?: string; backgroundColor?: string; loading?: boolean; color?: string; fontSize?: number; styleText?: StyleProp[]; } const styles = StyleSheet.create({ container: { paddingHorizontal: 14, justifyContent: 'center', height: 48, borderRadius: 2, marginBottom: 12 }, text: { ...sharedStyles.textMedium, ...sharedStyles.textAlignCenter }, disabled: { opacity: 0.3 } }); const Button = ({ type = 'primary', disabled = false, loading = false, fontSize = 16, title, onPress, backgroundColor, color, style, styleText, ...otherProps }: IButtonProps): React.ReactElement => { const { colors } = useTheme(); const isPrimary = type === 'primary'; let textColor = isPrimary ? colors.buttonText : colors.bodyText; if (color) { textColor = color; } return ( {loading ? ( ) : ( {title} )} ); }; export default Button;