ProgressBar.js 809 B

1234567891011121314151617181920212223242526272829303132
  1. import React from 'react' // eslint-disable-line no-unused-vars
  2. import { View, Text } from 'react-native'
  3. export default function ProgressBar (props) {
  4. const progress = props.progress || 0
  5. const total = props.total || 0
  6. const percentage = Math.round(progress / total * 100)
  7. const colorGreen = '#0b8600'
  8. const colorBlue = '#006bb7'
  9. return (
  10. <View style={{
  11. marginTop: 15,
  12. marginBottom: 15
  13. }}>
  14. <View
  15. style={{
  16. height: 5,
  17. overflow: 'hidden',
  18. backgroundColor: '#dee1e3'
  19. }}>
  20. <View style={{
  21. height: 5,
  22. backgroundColor: percentage === 100 ? colorGreen : colorBlue,
  23. width: percentage + '%'
  24. }} />
  25. </View>
  26. <Text>{percentage ? percentage + '%' : null}</Text>
  27. </View>
  28. )
  29. }