import Icon from '@components/Icon' 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 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, switchValue, switchDisabled, switchOnValueChange, iconBack, iconBackColor = 'secondary', loading = false, onPress }) => { const { theme } = useTheme() const loadingSpinkit = useMemo( () => ( ), [theme] ) return ( nativeEvent.state === State.ACTIVE && !loading && onPress && onPress() } > {iconFront && ( )} {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', paddingHorizontal: StyleConstants.Spacing.Global.PagePadding }, front: { flex: 2, flexDirection: 'row', alignItems: 'center' }, back: { flex: 1, flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center', marginLeft: StyleConstants.Spacing.M }, iconFront: { marginRight: 8 }, main: { flex: 1 }, title: { ...StyleConstants.FontStyle.M }, description: { ...StyleConstants.FontStyle.S, marginTop: StyleConstants.Spacing.XS, paddingHorizontal: StyleConstants.Spacing.Global.PagePadding }, content: { ...StyleConstants.FontStyle.M }, iconBack: { marginLeft: 8 } }) export default MenuRow