You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.8 KiB
85 lines
1.8 KiB
1 month ago
|
import React from 'react';
|
||
|
import { View, StyleSheet } from 'react-native';
|
||
|
import { Text } from 'react-native-paper';
|
||
|
|
||
|
|
||
|
interface ProgressProps {
|
||
|
statuses: number;
|
||
|
labels?: string[];
|
||
|
}
|
||
|
|
||
|
const Progress: React.FC<ProgressProps> = ({ statuses , labels = [] }) => {
|
||
|
return (
|
||
|
<View style={styles.mainContainer}>
|
||
|
<View style={styles.progressContainer}>
|
||
|
{labels.map((_, index) => (
|
||
|
<React.Fragment key={index}>
|
||
|
<View
|
||
|
style={[
|
||
|
styles.node,
|
||
|
index < statuses + 1 && styles.completedNode
|
||
|
]}
|
||
|
/>
|
||
|
{index < labels.length - 1 && (
|
||
|
<View
|
||
|
style={[
|
||
|
styles.line,
|
||
|
index < statuses&& styles.completedLine
|
||
|
]}
|
||
|
/>
|
||
|
)}
|
||
|
</React.Fragment>
|
||
|
))}
|
||
|
</View>
|
||
|
<View style={styles.labelsContainer}>
|
||
|
{labels.map((label, index) => (
|
||
|
<Text key={index} style={styles.label}>{label}</Text>
|
||
|
))}
|
||
|
</View>
|
||
|
</View>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
const styles = StyleSheet.create({
|
||
|
mainContainer: {
|
||
|
alignItems: 'center',
|
||
|
},
|
||
|
progressContainer: {
|
||
|
flexDirection: 'row',
|
||
|
alignItems: 'center',
|
||
|
justifyContent: 'center',
|
||
|
marginBottom: 10,
|
||
|
},
|
||
|
node: {
|
||
|
width: 20,
|
||
|
height: 20,
|
||
|
borderRadius: 10,
|
||
|
backgroundColor: '#E0E0E0',
|
||
|
},
|
||
|
completedNode: {
|
||
|
backgroundColor: '#4CAF50',
|
||
|
},
|
||
|
line: {
|
||
|
height: 2,
|
||
|
width: 40,
|
||
|
backgroundColor: '#E0E0E0',
|
||
|
},
|
||
|
completedLine: {
|
||
|
backgroundColor: '#4CAF50',
|
||
|
},
|
||
|
labelsContainer: {
|
||
|
flexDirection: 'row',
|
||
|
justifyContent: 'space-between',
|
||
|
width: '100%',
|
||
|
paddingHorizontal: 10,
|
||
|
},
|
||
|
label: {
|
||
|
fontSize: 12,
|
||
|
color: '#666',
|
||
|
textAlign: 'center',
|
||
|
width: 60,
|
||
|
},
|
||
|
});
|
||
|
|
||
|
export default Progress;
|