import React, { useCallback, useState } from 'react'; import { SvgProps } from 'react-native-svg'; import { PressableProps, ViewProps, View, } from 'react-native'; import { THEME_COLOR } from 'CONSTANTS'; import styled, { css } from 'styled-components/native'; import useDefaultStyles from './Colors'; interface ButtonProps extends PressableProps { icon?: React.FC; title: string; style?: ViewProps['style']; } const BaseButton = styled.Pressable` padding: 16px; border-radius: 8px; flex-direction: row; align-items: center; justify-content: center; flex-grow: 1; ${(props) => props.disabled && css` opacity: 0.25; `} `; const ButtonText = styled.Text<{ active?: boolean }>` color: ${THEME_COLOR}; font-weight: 600; ${props => props.active && css` color: white; `} `; const Button = React.forwardRef(function Button(props, ref) { const { icon: Icon, title, disabled, ...rest } = props; const defaultStyles = useDefaultStyles(); const [isPressed, setPressed] = useState(false); const handlePressIn = useCallback(() => setPressed(true), []); const handlePressOut = useCallback(() => setPressed(false), []); return ( {Icon && } {title} ); }); export default Button;