import Icon from '@components/Icon' import CustomText from '@components/Text' import { useAccessibility } from '@utils/accessibility/AccessibilityManager' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import { ColorDefinitions } from '@utils/styles/themes' import React, { useMemo } from 'react' import { Text, View } from 'react-native' import { Flow } from 'react-native-animated-spinkit' import { State, Switch, TapGestureHandler } from 'react-native-gesture-handler' export interface Props { iconFront?: any iconFrontColor?: ColorDefinitions title: string description?: string content?: string | React.ReactNode badge?: boolean switchValue?: boolean switchDisabled?: boolean switchOnValueChange?: () => void iconBack?: 'ChevronRight' | 'ExternalLink' | 'Check' iconBackColor?: ColorDefinitions loading?: boolean onPress?: () => void } const MenuRow: React.FC = ({ iconFront, iconFrontColor = 'primaryDefault', title, description, content, badge = false, switchValue, switchDisabled, switchOnValueChange, iconBack, iconBackColor = 'secondary', loading = false, onPress }) => { const { colors, theme } = useTheme() const { screenReaderEnabled } = useAccessibility() const loadingSpinkit = useMemo( () => ( ), [theme] ) return ( { if (typeof iconBack !== 'string') return // Let icon back handles the gesture if (nativeEvent.state === State.ACTIVE && !loading) { if (screenReaderEnabled && switchOnValueChange) { switchOnValueChange() } else { if (onPress) onPress() } } }} > {iconFront && ( )} {badge ? ( ) : null} {title} {content || switchValue !== undefined || iconBack ? ( {content ? ( typeof content === 'string' ? ( {content} ) : ( content ) ) : null} {switchValue !== undefined ? ( ) : null} {iconBack ? ( ) : null} {loading && loadingSpinkit} ) : null} {description ? ( {description} ) : null} ) } export default MenuRow