import Icon from '@components/Icon' 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 { StyleSheet, 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' 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 { theme } = useTheme() const { screenReaderEnabled } = useAccessibility() const loadingSpinkit = useMemo( () => ( ), [theme] ) return ( { 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} ) } const styles = StyleSheet.create({ base: { minHeight: 50 }, core: { flex: 1, flexDirection: 'row', paddingVertical: StyleConstants.Spacing.S }, front: { flex: 2, flexDirection: 'row', alignItems: 'center' }, back: { flex: 1, flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center', marginLeft: StyleConstants.Spacing.M }, iconFront: { marginRight: StyleConstants.Spacing.S }, main: { flex: 1 }, title: { ...StyleConstants.FontStyle.M }, description: { ...StyleConstants.FontStyle.S }, content: { ...StyleConstants.FontStyle.M }, iconBack: { marginLeft: 8 } }) export default MenuRow