import * as React from 'react'; import { View } from 'react-native'; import Node from '../node'; import Icon from '../icon'; import Row from '../row'; import Col from '../col'; import { withTheme } from '../theme'; import { createStylesWithTheme } from './style'; const prefixCls = 'steps'; export interface StepProps { title?: React.ReactNode; errorTitle?: React.ReactNode; extra?: React.ReactNode; description?: React.ReactNode; } export interface StepsProps { current?: number; status?: string; direction?: string; steps?: StepProps[]; type?: 'arrow' | 'default'; theme: AnnaNative.Theme; } const Steps: React.FC = props => { const { direction = 'horizontal', current = 0, steps, status, type, theme } = props; const styles = createStylesWithTheme(theme); const { colors } = theme; const { primary } = colors; const statusIconType = status === 'error' ? 'roundclosefill' : 'roundcheckfill'; const statusIconColor = status === 'error' ? '#f5222d' : '#1890FF'; const getTitle = (item: StepProps, index: number) => { if (index === current) { if (status === 'error') { return item.errorTitle || item.title; } } return item.title; }; if (direction === 'vertical') { return ( {steps?.map((item, index) => ( {index !== 0 && } {index !== steps.length - 1 && ( )} {index === 0 ? ( ) : ( )} {item.title} {item.extra} {item.description} ))} ); } if (type === 'arrow') { const span = 24 / (steps?.length || 1); return ( {steps?.map((step, index) => ( = index && styles[`${prefixCls}-arrow-step-active`], ]} > {step?.title} {index === steps.length - 1 ? null : ( = index && styles[`${prefixCls}-arrow-step-head-active`], ]} /> )} {index === 0 ? null : ( = index && styles[`${prefixCls}-arrow-step-tail-active`], ]} /> )} ))} ); } return ( {steps?.map((item, index) => ( {index < current ? : null} {index === current ? ( ) : null} {index > current ? ( ) : null} {getTitle(item, index)} ))} ); }; export default withTheme(Steps);