import React from 'react'; import { StyleSheet, View } from 'react-native'; import { StepProps, StepsProps } from './interface'; import StepHorizontal from './StepHorizontal'; import StepVertical from './StepVertical'; import createStyle from './styles/steps.style'; import { useTheme } from '../Theme/Theme'; const Steps: React.FC = ({ style, current = -1, data: propsData, direction = 'horizontal', collapse: propsCollapse, reverse: propsReverse, }) => { const token = useTheme(); const styles = createStyle(token); const collapse = direction === 'horizontal' && propsCollapse; const Step = direction === 'horizontal' ? StepHorizontal : StepVertical; const wrapperStyle = direction === 'horizontal' ? styles.wrapperHorizontal : styles.wrapperVertical; const reverse = propsReverse && direction === 'vertical'; const data = reverse ? propsData.reverse() : propsData; const inner = data.map((stepProps, dataIndex) => { const { status: propsStatus } = stepProps; let status: StepProps['status'] = 'wait'; const index = reverse ? data.length - dataIndex - 1 : dataIndex; if (index < current) { status = 'finish'; } else if (index === current) { status = 'process'; } return ( ); }); return ( {inner} ); }; export default Steps;