import { ActivityIndicator, I18nManager, ImageSourcePropType, ImageStyle, TextStyle, TouchableOpacity, View, ViewStyle, } from 'react-native'; import * as React from 'react'; import styled, { useTheme } from 'styled-components/native'; import { OIcon } from './'; import { css } from 'styled-components'; const StyledButton = styled.View` background-color: ${(props: any) => props.theme.colors.primary}; border-radius: 26px; border-width: 2px; height: 52px; border-color: ${(props: any) => props.theme.colors.primary}; flex-direction: row; align-items: center; justify-content: center; box-shadow: 1px 1px 2px #00000020; padding-left: 20px; padding-right: 20px; position: relative; ${(props: any) => props?.borderRadius && css` border-radius: ${typeof props?.borderRadius === 'string' ? props?.borderRadius : `${props?.borderRadius}px`}; `} ` const StyledButtonDisabled = styled(StyledButton)` background-color: ${(props: any) => props.theme.colors.disabled}; border-color: ${(props: any) => props.theme.colors.disabled}; ` const StyledText = styled.Text` font-size: 16px; color: ${(props: any) => props.theme.colors.btnFont}; margin-left: 10px; margin-right: 10px; font-family: 'Poppins-Regular'; ` const StyledTextDisabled = styled(StyledText)` color: ${(props: any) => props.theme.colors.primary}; ` const StyledImage = styled.Image` width: 20px; height: 20px; resize-mode: contain; ` const EndImage = styled.Image` width: 17px; height: 15px; resize-mode: contain; right: 17.5px; position: absolute; `; interface Props { testID?: string; isLoading?: boolean; isDisabled?: boolean; onClick?: () => void; style?: ViewStyle; parentStyle?: ViewStyle; disabledStyle?: ViewStyle; textStyle?: TextStyle; imgLeftSrc?: ImageSourcePropType | string; imgLeftStyle?: ImageStyle; imgRightSrc?: any; imgRightStyle?: ImageStyle; indicatorColor?: string; activeOpacity?: number; text?: string; isCircle?: boolean; bgColor?: string; borderColor?: string; loadingStyle?: ViewStyle; showNextIcon?: boolean; isDisabledWithSameStyles?: boolean; icon?: any; iconProps?: any useArrow?: boolean; } const OButton = (props: Props): React.ReactElement => { const theme = useTheme(); if (props.isDisabled) { return ( {props.text} ); } if (props.isLoading) { return ( ); } return ( {props.icon ? ( ) : null} {props.imgLeftSrc ? ( ) : null} {props.text ? ( {props.text} ) : null} {props.imgRightSrc ? ( ) : props.showNextIcon ? : null} ); } OButton.defaultProps = { isLoading: false, isDisabled: false, indicatorColor: 'white', activeOpacity: 0.5, }; export default OButton;